Skip to content
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

swarm/src/lib: Rework connection exports #2525

Merged
merged 1 commit into from
Feb 17, 2022

Conversation

mxinden
Copy link
Member

@mxinden mxinden commented Feb 17, 2022

Mostly to unblock @dignifiedquire, i.e. to expose ConnectionLimits. My bad, bug introduced with #2492.

I am surprised that the compiler didn't catch ConnectionLimits not being exposed, given that it is used in the public SwarmBuilder method connection_limits.


For a follow up pull request:

I am not happy with how we do exports in libp2p-swarm today, mostly as it does not seem to be consistent and thus not intuitive.

  • I like the idea of exposing modules like behaviour and protocols_handler as a exports grouping mechanism. Ideally with Adopt naming conventions that don't repeat names #2174, i.e. exposing libp2p_swarm::behaviour::Action and not libp2p_swarm::behaviour::NetworkBehaviourAction.
  • I want to prevent both accidental exposure of private types (e.g. Pool should never be exposed) as well as preventing to forget exposing a publicly used type (e.g. ConnectionLimits).

Anyone has opinions / suggestions on the above?

Copy link
Member

@dignifiedquire dignifiedquire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@dignifiedquire
Copy link
Member

  • I like the idea of exposing modules like behaviour and protocols_handler as a exports grouping mechanism. Ideally with Adopt naming conventions that don't repeat names #2174, i.e. exposing libp2p_swarm::behaviour::Action and not libp2p_swarm::behaviour::NetworkBehaviourAction.

💯

@thomaseizinger
Copy link
Contributor

preventing to forget exposing a publicly used type (e.g. ConnectionLimits).

Moving most of the tests into tests/ can help with that. Doctests also run as a separate crate can thus be used to enforce the public API.

@thomaseizinger
Copy link
Contributor

I want to prevent both accidental exposure of private types (e.g. Pool should never be exposed)

Perhaps adding trybuild tests could catch this? It is a bit excessive though 😁

@mxinden mxinden merged commit eeb3504 into libp2p:master Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants