Skip to content

Commit

Permalink
Merge pull request #6 from libp2p/docs/overwriten-functions
Browse files Browse the repository at this point in the history
docs: overwritten functions
  • Loading branch information
vasco-santos authored Feb 14, 2019
2 parents 1e4ce8c + ad1057f commit 1d04874
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
language: node_js
cache: npm
stages:
- check
- test
- cov

node_js:
- '10'

os:
- linux
- osx
- windows

script: npx nyc -s npm run test -- --bail
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov

jobs:
include:
- stage: check
script:
- npx aegir commitlint --travis
- npx aegir dep-check
- npm run lint

notifications:
email: false
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ js-libp2p-pubsub

## Usage

A pubsub implementation **MUST** override the `_processConnection`, `publish`, `subscribe` and `unsubscribe` functions. `add_peer` and `remove_peer` may be overwritten if the pubsub implementation needs to add custom logic when peers are added and remove. All the remaining functions **MUST NOT** be overwritten.
A pubsub implementation **MUST** override the `_processConnection`, `publish`, `subscribe` and `unsubscribe` functions.

Other functions, such as `_addPeer`, `_removePeer`, `_onDial`, `start` and `stop` may be overwritten if the pubsub implementation needs to add custom logic on them. It is important pointing out that `start` and `stop` **must** call `super`. The `start` function is responsible for mounting the pubsub protocol onto the libp2p node and sending its' subscriptions to every peer conneceted, while the `stop` function is responsible for unmounting the pubsub protocol and shutting down every connection

All the remaining functions **MUST NOT** be overwritten.

The following example aims to show how to create your pubsub implementation extending this base protocol. The pubsub implementation will handle the subscriptions logic.

Expand Down
2 changes: 0 additions & 2 deletions ci/Jenkinsfile

This file was deleted.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"err-code": "^1.1.2",
"length-prefixed-stream": "^1.6.0",
"protons": "^1.0.1",
"pull-length-prefixed": "^1.3.1",
"pull-pushable": "^2.2.0",
"pull-stream": "^3.6.9",
"time-cache": "~0.3.0"
},
"contributors": [
Expand Down

0 comments on commit 1d04874

Please sign in to comment.