-
Notifications
You must be signed in to change notification settings - Fork 242
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
Refactor subspace-networking module structure. #1867
Conversation
- gather custom protocols and request handlers in the “protocol” module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I like compose
name. Maybe we can make it a constructor on Node
? We have precedents with constructors returning a tuple of instance being constructed + worker, in this case NodeRunner
is a worker.
Also please don't use mod.rs
. We don't have them in the repo and we don't need to introduce them, better use module_name.rs
as we did prior to this.
Also |
I don't want to overload node.rs, also this "constructor" has enough logic to be a separate entity. WDUT about
I wanted to reduce the file number in the root folder, and
We have a separate |
If we have a builder data structure with useful methods - sure, otherwise I see nothing wrong with having it as a method in
Should those handler be in a submodule of request-response then? |
# Conflicts: # crates/subspace-networking/src/lib.rs # crates/subspace-networking/src/protocols/peer_info.rs
It's correct if we follow the GoF pattern definition. So, I renamed
I would leave those separate because |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave those separate because request-responses is independent and this extra-dependency won't bring any benefit at all. However, I renamed request to request-response as you suggested and renamed request-responses to request-responses-factory. We confused request-responses with the libp2p protocol with a similar name for some time. This renaming should help to avoid confusion from now on.
I do not see why they are separate. One is inherently used with another. And I it made sense to call it what it was despite libp2p having the same module name. It just doesn't look consistent right now. While factory makes sense for what it does, from libp2p point of view Behaviour was the consistent name, I don't see why we want to have that specific protocol follow a different naming convention all of a sudden.
- rename RequestResponseFactory to RequestResponseFactoryBehaviour
I'm not sure I understood you 100%. The request factory is an abstract entity and doesn't know about its usage. Different handlers could be passed to it even from the outer crates and having handlers to be submodule of factory is not necessary. However, the "-Behaviour" suffix is probably a good idea, I initially omitted it because of the long name but since it immediately caused confusion it's better to add it back. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understood you 100%. The request factory is an abstract entity and doesn't know about its usage. Different handlers could be passed to it even from the outer crates and having handlers to be submodule of factory is not necessary. However, the "-Behaviour" suffix is probably a good idea, I initially omitted it because of the long name but since it immediately caused confusion it's better to add it back.
What I meant is that it would be a factory if it produced multiple things, but it is a single behavior, not multiple, hence factory as part of the name doesn't make a lot of sense to me, it is simply not a factory. RequestResponseFactoryBehaviour
is a bit less bad name in a sense that it is one behavior, but it kind of instantiates multiple request response protocols internally.
Please squash this PR on merge.
Refactor the module structure of the `subspace-networking` crate: gather custom protocols and request handlers in the “protocols” module.
This PR changes the module structure of the
subspace-networking
crate.Changes:
create
module tocomposer
as well as the related function. We should use a noun for the module name and neither "creation" nor "creator" seem appropriate.protocols
modulerequest-reponses
request factory torequests
modulerequest_handlers
module tohandlers
(requests::handlers)mod.rs
forprotocol
andrequests
modules instead of extra files in the related foldersCode contributor checklist: