This repository has been archived by the owner on Jun 26, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: interface pubsub #60
feat: interface pubsub #60
Changes from 3 commits
af3487a
7d5b3c4
d8671f9
edcc91e
5751c9b
ca7b433
1c6598a
c9cc4ec
ec5ae25
f209d04
d5ffc49
a45ff8d
94c1806
956067a
05491ac
2152105
f389446
34e69ed
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 think the interface should only allow subscription/unsubscription of a single topic at a time.
Attaching a handler to multiple topics at once feels like an anti-pattern, or at least a less primary interface, in the same way we were previously attaching multiple topics to multiple messages at once in
publish
.I think this will simplify some of the underlying implementations, too. The body of our subscription code looks roughly like:
for (const topic of topics) { /* doSubscribe(topic) */ }
. We would be able to remove this outer loop and better support extended behavior.Also, go-libp2p-pubsub's interface for subscribing is for a single topic at a time, for what its worth.
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 agree that the API would look better with one topic. Taking into account that we are doing several breaking changes in pubsub, I think we should also change this.
The libp2p API doc also says a single topic, so we were supporting it below in the stack but we were not mentioning it. However, this should be pointed in the migration guide
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.
What about publish? Should we also just accept one topic per API call? That's how we have it in libp2p main docs as well
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.
👍 for publish also accepting a single topic per API call
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 will update it