Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

TransportManager Refactoring to fix #300 #302

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

TransportManager Refactoring to fix #300 #302

wants to merge 4 commits into from

Conversation

nikor
Copy link

@nikor nikor commented Jan 9, 2019

Encapsulates transports in TransportManager and moves the listeners outside the transport object.

One of the test in js-libp2p fails with this pull request. There is a fix for that test on this branch: https://github.com/nikor/js-libp2p/tree/js-libp2p-switch_300

@dirkmc
Copy link

dirkmc commented Jan 9, 2019

I would suggest using a Map for TransportManager.transports. This will allow you to simplify some of the other code. For example getTransports() can be implemented as

return new Map([...this.transports].map(([k, v]) => [k, v.transport]))

@nikor
Copy link
Author

nikor commented Jan 9, 2019

I will change it to a map, and i will try to make test pass as well :)

second part of fixing issue #300
third part of fixing issue #300
@jacobheun
Copy link
Contributor

@nikor tests seem to be okay. The commitlint is the main thing that's failing. (Code coverage is also "failing", but it's a nominal drop in percentage). When committing dont capitalize the first letter of the commit message. fix: Remove listeners from transport object should be fix: remove listeners from transport object. It's a bit silly, but it keeps the changelog consistent.

Since this is going to be a breaking change, I think we should take advantage of the change to naming transport related things. Right now we have things like switch.transport.transports[key].transport, which makes it pretty easy to get lost. Some quick thoughts on possible changes:

Use switch.transportManager instead of switch.transport for easier reading.
switch.transportManager.get(key) and maybe privatize the transportManager._transports map
switch.transportManager.getAll() instead of getTransports

Thanks for submitting a PR for this!

@nikor
Copy link
Author

nikor commented Jan 9, 2019

@jacobheun Thank you for explaining why commitlint failed. I will stick to lowercase in the future :)
I will make a new commit with the naming changes.

the comments related to the changes can be seen here:
#302 (comment)
#302 (comment)
@nikor
Copy link
Author

nikor commented Jan 9, 2019

Okay, i think the api changes is done.
I have make the changes need to js-libp2p on this branch https://github.com/nikor/js-libp2p/tree/js-libp2p-switch_300

@daviddias
Copy link
Member

@jacobheun with the refactor, these need to be remade or closed. I'll let you do the review

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants