waku-org / js-waku

JavaScript implementation of Waku v2
https://js.waku.org
Apache License 2.0
162 stars 41 forks source link

chore: refactor `ConnectionManager` for maintainability #1969

Open danisharora099 opened 2 months ago

danisharora099 commented 2 months ago

This is a change request

Problem

We introduced a ConnectionManager a while ago to gain more control over how dials occur within a js-waku node, and slowly a lot of new APIs, refactors, etc started to bloat which is our current implementation. Our current implementation is ~580 lines, and very coupled together -- making it quite unreadable and unmaintainable.

Proposed Solutions

Split the ConnectionManager class into multiple classes, aiming to adhere to the Single Responsibility Principle.

Suggestions for the split based on the current type defs for the class:

Notes

some inspiration here: https://github.com/libp2p/js-libp2p/tree/main/packages/libp2p/src/connection-manager

weboko commented 2 months ago

Postponed till we have https://github.com/waku-org/js-waku/issues/1595 done