This repository was archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 110
feature: add pubsub (tests and API Spec) #101
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
562a0bb
chore: update contributors
daviddias e9506ff
chore: release version v0.22.1
daviddias 56cd45e
chore: update deps
daviddias 74003a7
feat: add first pass of pubsub tests (running in js-ipfs-api)
haadcode eb65994
moved pubsub-message tests to js-ipfs-api as it is specific to js-ipf…
daviddias a63988b
docs: add PubSub interface spec, refactor tests
daviddias d004577
fix: fix a bunch of issues (i.e: identify race condition)
daviddias 1a82890
feat: new event based API
dignifiedquire 142c417
Merge branch 'master' into tests/pubsub
daviddias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
pubsub API | ||
========== | ||
|
||
#### `pubsub.subscribe` | ||
|
||
> Subscribe to a pubsub topic. | ||
|
||
##### `Go` **WIP** | ||
|
||
##### `JavaScript` - ipfs.pubsub.subscribe(topic, options, handler, callback) | ||
|
||
- `topic: string` | ||
- `options: Object` - (Optional), might contain the following properties: | ||
- `discover`: type: Boolean - Will use the DHT to find other peers. | ||
- `handler: (msg) => ()` - Event handler which will be called with a message object everytime one is received. The `msg` has the format `{from: string, seqno: Buffer, data: Buffer, topicCIDs: Array<string>}`. | ||
- `callback: (Error) => ()` (Optional) Called once the subscription is established. | ||
|
||
If no `callback` is passed, a [promise][] is returned. | ||
|
||
> _In the future, topic can also be type of TopicDescriptor (https://github.com/libp2p/pubsub-notes/blob/master/flooding/flooding.proto#L23). However, for now, only strings are supported._ | ||
|
||
#### `pubsub.unsubscribe` | ||
|
||
> Unsubscribes from a pubsub topic. | ||
|
||
##### `Go` **WIP** | ||
|
||
##### `JavaScript` - `ipfs.pubsub.unsubscribe(topic, handler)` | ||
|
||
- `topic: string` - The topic to unsubscribe from | ||
- `handler: (msg) => ()` - The handler to remove. | ||
|
||
This works like `EventEmitter.removeListener`, as that only the `handler` passed to a `subscribe` call before is removed from listening. The underlying subscription will only be canceled once all listeners for a topic have been removed. | ||
|
||
#### `pubsub.publish` | ||
|
||
> Publish a data message to a pubsub topic. | ||
|
||
##### `Go` **WIP** | ||
|
||
##### `JavaScript` - ipfs.pubsub.publish(topic, data, callback) | ||
|
||
- `topic: string` | ||
- `data: buffer` - The actual message to send | ||
- `callback: (Error) => ()` - Calls back with an error or nothing if the publish was successfull. | ||
|
||
If no `callback` is passed, a promise is returned. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please complete There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
#### `pubsub.ls` | ||
|
||
> Returns the list of subscriptions the peer is subscribed to. | ||
|
||
##### `Go` **WIP** | ||
|
||
##### `JavaScript` - ipfs.pubsub.ls(topic, callback) | ||
|
||
- `topic: string` | ||
- `callback: (Error, Array<string>>) => ()` - Calls back with an error or a list of topicCIDs that this peer is subscribed to. | ||
|
||
If no `callback` is passed, a promise is returned. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing docs on the value that is resolved |
||
#### `pubsub.peers` | ||
|
||
> Returns the peers that are subscribed to one topic. | ||
|
||
##### `Go` **WIP** | ||
|
||
##### `JavaScript` - ipfs.pubsub.peers(topic, callback) | ||
|
||
- `topic: string` | ||
- `callback: (Error, Array<string>>) => ()` - Calls back with an error or a list of peer ids subscribed to the `topic`. | ||
|
||
If no `callback` is passed, a promise is returned. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
It is missing the description of
data
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.
🛎
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.
fixed