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

Improve builder API #964

Open
Tracked by #777
Menduist opened this issue Oct 12, 2023 · 0 comments
Open
Tracked by #777

Improve builder API #964

Menduist opened this issue Oct 12, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@Menduist
Copy link
Contributor

Menduist commented Oct 12, 2023

Building a switch is no easy task. libp2p being a modular system, we have to build 10s of objects, in a particular order, and ideally in a quite generic way

The current builder system has a few flaws:

  • It is not modular at all, which means:
    • Code outside of libp2p cannot be integrated into it
    • It needs to import every module of libp2p that it can build, even if the user doesn't care about said module (especially bad when the module imports optional dependencies, like the transports)
    • Every time we add something to libp2p, we also need to add it to this file
  • It's quite hard to maintain

With that in mind, we need to find a new system.
A good starting point might be to look at other libp2ps, and how to they build their switches.

Last time I did this exercice, I've seen that they mostly used hard-coded builders like ours, but go-libp2p wanted to switch to a dependency injection pattern.

AFAIK, we don't have a good DI library in Nim, so I've started a PoC a few years ago: #701
However, it's quite rough, and needs more work

@Menduist Menduist mentioned this issue Oct 12, 2023
21 tasks
@Menduist Menduist added the enhancement New feature or request label Oct 12, 2023
@kaiserd kaiserd moved this to new in nim-libp2p May 2, 2024
@kaiserd kaiserd moved this from new to backlog in nim-libp2p May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: backlog
Development

No branches or pull requests

1 participant