-
-
Notifications
You must be signed in to change notification settings - Fork 562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library - Slim down the NodeManagerWorker
for node / secure channel
#6710
Comments
May I work on this issue too please? :) |
@Darioazzali of course, all yours. |
Have a couple of doubt: 1. Response from
|
Hi @Darioazzali. 1. Response from delete_secure_channel and show_secure_channel
That should be the same thing with 2. Wrappers The idea is to be eventually able to use the So the format is more like pub(super) async fn xxxx_secure_channel(
&mut self,
header: &RequestHeader,
request: &XxxxSecureChannelRequest,
ctx: &Context,
) -> Result<Response<XxxxxSecureChannelResponse>, Response<Error>> {
self.node_manager
.xxxxx_secure_channel(ctx, request.parameter1, request.parameter2)
.await
.map(|secure_channel| {
Response::ok(req).body(XxxxxSecureChannelResponse::new(
.....
))
})
} An example of this would be |
Thanks for the quick response @etorreborre. 1
|
@Darioazzali you raise some excellent points. We currently have too many places where we handle untyped data (in general What I propose is to start by well-typing the This is necessarily going to be a bit awkward at first but let's work our way up and eventually create issues to better type the rest of the stack. |
Thnaks @etorreborre. (Post, ["node", "secure_channel"]) => {
encode_response(self.create_secure_channel(req, dec.decode()?, ctx).await)?
} pub(super) async fn create_secure_channel(
&mut self,
req: &RequestHeader,
create_secure_channel: CreateSecureChannel,
ctx: &Context,
) -> Result<Response<CreateSecureChannelResponse>, Response<Error>> {
let CreateSecureChannel {
addr,
authorized_identifiers,
timeout,
identity_name: identity,
credential_name,
..
} = create_secure_channel; with a typed request like this: #[derive(Debug, Clone, Decode, Encode)]
#[rustfmt::skip]
#[cbor(map)]
pub struct CreateSecureChannel {
#[n(1)] pub addr: MultiAddr,
#[n(2)] pub authorized_identifiers: Option<Vec<Identifier>>,
#[n(4)] pub timeout: Option<Duration>,
#[n(5)] pub identity_name: Option<String>,
#[n(6)] pub credential_name: Option<String>,
} Error handling is simply managed by the |
@Darioazzali correct. Then, once we extract the request parameters, we call a well-typed implementation at the |
The purpose of the
NodeManagerWorker
is to be started as aWorker
on a node and receive requests to create entities on that node: inlets, outlets, secure channels, etc...This should be the only responsibility of the
NodeManagerWorker
:Requests
, with a specific pathNodeManager
NodeManager
and make aResponse
out of itExample
For example if we look at this dispatched request:
The implementation in the
NodeManagerWorker
is:It should actually be something like:
In the code above all the logic is handled by the
NodeManager
and theNodeManagerWorker
only deals with Request/Responses.Desired behavior
In this issue handle refactoring the following (each line corresponds to some paths in the
handle_request
method):Additional notes
You can follow the way
relays
are handled in this PR (here is the section on relays).You will notice that the
NodeManagerWorker
does not contain a direct reference to aNodeManager
but to anInMemoryNode
, which itself contains aNodeManager
.This intermediary layer is only required to monitor sessions for relays and portals. In most cases when you call
self.node_manager
inNodeManagerWorker
thenode_manager
can be dereferenced to aNodeManager
on which regular calls can be made: to list workers, get a credential etc....Note
Related epic: #6237
We love helping new contributors! ❤️
If you have questions or need help as you explore, please join us on Discord. If you're looking for other issues to contribute to, please checkout our good first issues.
The text was updated successfully, but these errors were encountered: