-
Notifications
You must be signed in to change notification settings - Fork 109
feature: add pubsub (tests and API Spec) #101
Changes from 8 commits
562a0bb
e9506ff
56cd45e
74003a7
eb65994
a63988b
d004577
1a82890
142c417
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
<a name="0.22.1"></a> | ||
## [0.22.1](https://github.com/ipfs/interface-ipfs-core/compare/v0.22.0...v0.22.1) (2016-12-10) | ||
|
||
|
||
### Features | ||
|
||
* **object:** add template option to object.new ([2f23617](https://github.com/ipfs/interface-ipfs-core/commit/2f23617)) | ||
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. why is there a changelog in a pr? 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. It seems that is from a rebase |
||
|
||
|
||
|
||
<a name="0.22.0"></a> | ||
# [0.22.0](https://github.com/ipfs/interface-ipfs-core/compare/v0.21.0...v0.22.0) (2016-11-24) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "interface-ipfs-core", | ||
"version": "0.22.0", | ||
"version": "0.22.1", | ||
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. why is there a version bump in a PR? 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. same as #101 (comment) |
||
"description": "A test suite and interface you can use to implement a IPFS core interface.", | ||
"main": "src/index.js", | ||
"scripts": { | ||
|
@@ -28,26 +28,26 @@ | |
"dependencies": { | ||
"async": "^2.1.4", | ||
"bl": "^1.1.2", | ||
"bs58": "^3.0.0", | ||
"bs58": "^3.1.0", | ||
"chai": "^3.5.0", | ||
"concat-stream": "^1.5.2", | ||
"detect-node": "^2.0.3", | ||
"ipfs-block": "^0.5.0", | ||
"ipld-dag-pb": "^0.9.0", | ||
"ipfs-block": "^0.5.3", | ||
"ipld-dag-pb": "^0.9.3", | ||
"multiaddr": "^2.1.1", | ||
"multihashes": "^0.3.0", | ||
"readable-stream": "2.1.5" | ||
"multihashes": "^0.3.1", | ||
"readable-stream": "2.2.2" | ||
}, | ||
"devDependencies": { | ||
"aegir": "^9.2.1" | ||
"aegir": "^9.3.0" | ||
}, | ||
"contributors": [ | ||
"David Dias <daviddias.p@gmail.com>", | ||
"Friedel Ziegelmayer <dignifiedquire@gmail.com>", | ||
"Greenkeeper <support@greenkeeper.io>", | ||
"Richard Littauer <richard.littauer@gmail.com>", | ||
"Stephen Whitmore <stephen.whitmore@gmail.com>", | ||
"Victor Bjelkholm <victorbjelkholm@gmail.com>", | ||
"greenkeeperio-bot <support@greenkeeper.io>", | ||
"nginnever <ginneversource@gmail.com>" | ||
] | ||
} |
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