mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-04-24 20:02:20 +00:00
chore: clean up stream-muxer
This commit is contained in:
parent
46eac39626
commit
101cf22cc9
35
src/stream-muxer/.gitignore
vendored
35
src/stream-muxer/.gitignore
vendored
@ -1,35 +0,0 @@
|
||||
**/node_modules/
|
||||
**/*.log
|
||||
test/repo-tests*
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
coverage
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
build
|
||||
|
||||
# Dependency directory
|
||||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
|
||||
node_modules
|
||||
|
||||
dist
|
||||
package-lock.json
|
@ -1,34 +0,0 @@
|
||||
**/node_modules/
|
||||
**/*.log
|
||||
test/repo-tests*
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
|
||||
coverage
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
build
|
||||
|
||||
# Dependency directory
|
||||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
|
||||
node_modules
|
||||
|
||||
test
|
@ -1,17 +0,0 @@
|
||||
language: node_js
|
||||
cache: npm
|
||||
stages:
|
||||
- check
|
||||
|
||||
node_js:
|
||||
- '10'
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- stage: check
|
||||
script:
|
||||
- npx aegir dep-check
|
||||
- npm run lint
|
||||
|
||||
notifications:
|
||||
email: false
|
@ -1,173 +0,0 @@
|
||||
<a name="0.8.0"></a>
|
||||
# [0.8.0](https://github.com/libp2p/interface-stream-muxer/compare/v0.7.0...v0.8.0) (2019-09-20)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add onStreamEnd, muxer.streams and timeline ([#56](https://github.com/libp2p/interface-stream-muxer/issues/56)) ([0f60832](https://github.com/libp2p/interface-stream-muxer/commit/0f60832))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* This adds new validations to the stream muxer, which will cause existing tests to fail.
|
||||
|
||||
|
||||
|
||||
<a name="0.7.0"></a>
|
||||
# [0.7.0](https://github.com/libp2p/interface-stream-muxer/compare/v0.6.0...v0.7.0) (2019-09-16)
|
||||
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* API changes and switch to async await ([#55](https://github.com/libp2p/interface-stream-muxer/issues/55)) ([dd837ba](https://github.com/libp2p/interface-stream-muxer/commit/dd837ba))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* the API is now async / await. See https://github.com/libp2p/interface-stream-muxer/pull/55#issue-275014779 for a summary of the changes.
|
||||
|
||||
|
||||
|
||||
<a name="0.6.0"></a>
|
||||
# [0.6.0](https://github.com/libp2p/interface-stream-muxer/compare/v0.5.9...v0.6.0) (2018-11-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* improve the close test ([d9c8681](https://github.com/libp2p/interface-stream-muxer/commit/d9c8681))
|
||||
|
||||
|
||||
|
||||
<a name="0.5.9"></a>
|
||||
## [0.5.9](https://github.com/libp2p/interface-stream-muxer/compare/v0.5.8...v0.5.9) (2017-12-14)
|
||||
|
||||
|
||||
|
||||
<a name="0.5.8"></a>
|
||||
## [0.5.8](https://github.com/libp2p/interface-stream-muxer/compare/v0.5.7...v0.5.8) (2017-12-14)
|
||||
|
||||
|
||||
|
||||
<a name="0.5.7"></a>
|
||||
## [0.5.7](https://github.com/libp2p/interface-stream-muxer/compare/v0.5.6...v0.5.7) (2017-03-16)
|
||||
|
||||
|
||||
|
||||
<a name="0.5.6"></a>
|
||||
## [0.5.6](https://github.com/libp2p/interface-stream-muxer/compare/v0.5.5...v0.5.6) (2017-02-09)
|
||||
|
||||
|
||||
|
||||
<a name="0.5.5"></a>
|
||||
## [0.5.5](https://github.com/libp2p/interface-stream-muxer/compare/v0.5.4...v0.5.5) (2017-01-24)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* when things are in the same process, there is a order to them :) ([1635977](https://github.com/libp2p/interface-stream-muxer/commit/1635977))
|
||||
|
||||
|
||||
|
||||
<a name="0.5.4"></a>
|
||||
## [0.5.4](https://github.com/libp2p/interface-stream-muxer/compare/v0.5.3...v0.5.4) (2017-01-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* avoid making webpacky funky by not trying to inject tcp ([6695b80](https://github.com/libp2p/interface-stream-muxer/commit/6695b80))
|
||||
|
||||
|
||||
|
||||
<a name="0.5.3"></a>
|
||||
## [0.5.3](https://github.com/libp2p/interface-stream-muxer/compare/v0.5.2...v0.5.3) (2017-01-19)
|
||||
|
||||
|
||||
|
||||
<a name="0.5.2"></a>
|
||||
## [0.5.2](https://github.com/libp2p/interface-stream-muxer/compare/v0.5.1...v0.5.2) (2017-01-19)
|
||||
|
||||
|
||||
|
||||
<a name="0.5.1"></a>
|
||||
## [0.5.1](https://github.com/libp2p/interface-stream-muxer/compare/v0.5.0...v0.5.1) (2017-01-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* some fixes for incorrect tests ([23a75d1](https://github.com/libp2p/interface-stream-muxer/commit/23a75d1))
|
||||
|
||||
|
||||
|
||||
<a name="0.5.0"></a>
|
||||
# [0.5.0](https://github.com/libp2p/interface-stream-muxer/compare/v0.4.0...v0.5.0) (2016-11-03)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* move to next aegir ([11980ac](https://github.com/libp2p/interface-stream-muxer/commit/11980ac))
|
||||
|
||||
|
||||
|
||||
<a name="0.4.0"></a>
|
||||
# [0.4.0](https://github.com/libp2p/interface-stream-muxer/compare/v0.3.1...v0.4.0) (2016-09-06)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **api:** update the interface usage from dial to dialer and listen to listener ([5069679](https://github.com/libp2p/interface-stream-muxer/commit/5069679))
|
||||
* **pull:** migration to pull streams. Upgrade tests to use mocha as ([cc3130f](https://github.com/libp2p/interface-stream-muxer/commit/cc3130f))
|
||||
* **tests:** add closing tests, make sure errors are propagated ([c06da3b](https://github.com/libp2p/interface-stream-muxer/commit/c06da3b))
|
||||
* **tests:** stub test for aegir to verify ([949faf0](https://github.com/libp2p/interface-stream-muxer/commit/949faf0))
|
||||
|
||||
|
||||
|
||||
<a name="0.3.1"></a>
|
||||
## [0.3.1](https://github.com/libp2p/interface-stream-muxer/compare/v0.3.0...v0.3.1) (2016-03-06)
|
||||
|
||||
|
||||
|
||||
<a name="0.3.0"></a>
|
||||
# [0.3.0](https://github.com/libp2p/interface-stream-muxer/compare/v0.2.5...v0.3.0) (2016-03-06)
|
||||
|
||||
|
||||
|
||||
<a name="0.2.5"></a>
|
||||
## [0.2.5](https://github.com/libp2p/interface-stream-muxer/compare/v0.2.4...v0.2.5) (2015-12-12)
|
||||
|
||||
|
||||
|
||||
<a name="0.2.4"></a>
|
||||
## [0.2.4](https://github.com/libp2p/interface-stream-muxer/compare/v0.2.3...v0.2.4) (2015-07-22)
|
||||
|
||||
|
||||
|
||||
<a name="0.2.3"></a>
|
||||
## [0.2.3](https://github.com/libp2p/interface-stream-muxer/compare/v0.2.2...v0.2.3) (2015-07-15)
|
||||
|
||||
|
||||
|
||||
<a name="0.2.2"></a>
|
||||
## [0.2.2](https://github.com/libp2p/interface-stream-muxer/compare/v0.2.1...v0.2.2) (2015-07-15)
|
||||
|
||||
|
||||
|
||||
<a name="0.2.1"></a>
|
||||
## [0.2.1](https://github.com/libp2p/interface-stream-muxer/compare/v0.2.0...v0.2.1) (2015-07-14)
|
||||
|
||||
|
||||
|
||||
<a name="0.2.0"></a>
|
||||
# [0.2.0](https://github.com/libp2p/interface-stream-muxer/compare/v0.1.1...v0.2.0) (2015-07-14)
|
||||
|
||||
|
||||
|
||||
<a name="0.1.1"></a>
|
||||
## [0.1.1](https://github.com/libp2p/interface-stream-muxer/compare/v0.1.0...v0.1.1) (2015-07-14)
|
||||
|
||||
|
||||
|
||||
<a name="0.1.0"></a>
|
||||
# 0.1.0 (2015-07-13)
|
||||
|
||||
|
||||
|
@ -1,22 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 David Dias
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
@ -1,13 +1,5 @@
|
||||
# interface-stream-muxer
|
||||
|
||||
[](http://protocol.ai)
|
||||
[](http://libp2p.io/)
|
||||
[](http://webchat.freenode.net/?channels=%23libp2p)
|
||||
[](https://discuss.libp2p.io)
|
||||
[](https://travis-ci.com/libp2p/interface-stream-muxer)
|
||||
[](https://david-dm.org/libp2p/interface-stream-muxer)
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
> A test suite and interface you can use to implement a stream muxer. "A one stop shop for all your muxing needs"
|
||||
|
||||
The primary goal of this module is to enable developers to pick and swap their stream muxing module as they see fit for their application, without having to go through shims or compatibility issues. This module and test suite was heavily inspired by [abstract-blob-store](https://github.com/maxogden/abstract-blob-store).
|
||||
@ -16,15 +8,10 @@ Publishing a test suite as a module lets multiple modules all ensure compatibili
|
||||
|
||||
The API is presented with both Node.js and Go primitives, however, there is no actual limitations for it to be extended for any other language, pushing forward the cross compatibility and interop through different stacks.
|
||||
|
||||
## Lead Maintainer
|
||||
|
||||
[Jacob Heun](https://github.com/jacobheun/)
|
||||
|
||||
## Modules that implement the interface
|
||||
|
||||
- [JavaScript libp2p-spdy](https://github.com/libp2p/js-libp2p-spdy)
|
||||
- [JavaScript libp2p-mplex](https://github.com/libp2p/js-libp2p-mplex)
|
||||
- [Go spdy, muxado, yamux and multiplex](https://github.com/jbenet/go-stream-muxer)
|
||||
- [js-libp2p-spdy](https://github.com/libp2p/js-libp2p-spdy)
|
||||
- [js-libp2p-mplex](https://github.com/libp2p/js-libp2p-mplex)
|
||||
|
||||
Send a PR to add a new one if you happen to find or write one.
|
||||
|
||||
@ -36,12 +23,10 @@ Include this badge in your readme if you make a new module that uses interface-s
|
||||
|
||||
## Usage
|
||||
|
||||
### JS
|
||||
|
||||
Install `interface-stream-muxer` as one of the dependencies of your project and as a test file. Then, using `mocha` (for JavaScript) or a test runner with compatible API, do:
|
||||
|
||||
```js
|
||||
const test = require('interface-stream-muxer')
|
||||
const test = require('libp2p-interfaces/src/stream-muxer/tests')
|
||||
|
||||
const common = {
|
||||
async setup () {
|
||||
@ -56,17 +41,11 @@ const common = {
|
||||
test(common)
|
||||
```
|
||||
|
||||
### Go
|
||||
|
||||
> WIP
|
||||
|
||||
## API
|
||||
|
||||
### JS
|
||||
|
||||
A valid (one that follows this abstraction) stream muxer, must implement the following API:
|
||||
|
||||
#### `const muxer = new Muxer([options])`
|
||||
### `const muxer = new Muxer([options])`
|
||||
|
||||
Create a new _duplex_ stream that can be piped together with a connection in order to allow multiplexed communications.
|
||||
|
||||
@ -124,7 +103,7 @@ pipe(conn, muxer, conn) // conn is duplex connection to another peer
|
||||
```
|
||||
* `maxMsgSize` - The maximum size in bytes the data field of multiplexed messages may contain (default 1MB)
|
||||
|
||||
#### `muxer.onStream`
|
||||
### `muxer.onStream`
|
||||
|
||||
Use this property as an alternative to passing `onStream` as an option to the `Muxer` constructor.
|
||||
|
||||
@ -134,7 +113,7 @@ const muxer = new Muxer()
|
||||
muxer.onStream = stream => { /* ... */ }
|
||||
```
|
||||
|
||||
#### `muxer.onStreamEnd`
|
||||
### `muxer.onStreamEnd`
|
||||
|
||||
Use this property as an alternative to passing `onStreamEnd` as an option to the `Muxer` constructor.
|
||||
|
||||
@ -144,7 +123,7 @@ const muxer = new Muxer()
|
||||
muxer.onStreamEnd = stream => { /* ... */ }
|
||||
```
|
||||
|
||||
#### `const stream = muxer.newStream([options])`
|
||||
### `const stream = muxer.newStream([options])`
|
||||
|
||||
Initiate a new stream with the remote. Returns a [duplex stream](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#duplex-it).
|
||||
|
||||
@ -158,7 +137,7 @@ const stream = muxer.newStream()
|
||||
pipe([1, 2, 3], stream, consume)
|
||||
```
|
||||
|
||||
#### `const streams = muxer.streams`
|
||||
### `const streams = muxer.streams`
|
||||
|
||||
The streams property returns an array of streams the muxer currently has open. Closed streams will not be returned.
|
||||
|
||||
@ -168,39 +147,3 @@ muxer.streams.map(stream => {
|
||||
console.log(stream.id)
|
||||
})
|
||||
```
|
||||
|
||||
### Go
|
||||
|
||||
#### Attach muxer to a Connection
|
||||
|
||||
```go
|
||||
muxedConn, err := muxer.Attach(conn, isListener)
|
||||
```
|
||||
|
||||
This method attaches our stream muxer to an instance of [Connection](https://github.com/libp2p/interface-connection/blob/master/src/connection.js) defined by [interface-connection](https://github.com/libp2p/interface-connection).
|
||||
|
||||
If `err` is passed, no operation should be made in `conn`.
|
||||
|
||||
`isListener` is a bool that tells the side of the socket we are, `isListener = true` for listener/server and `isListener = false` for dialer/client side.
|
||||
|
||||
`muxedConn` interfaces our established Connection with the other endpoint, it must offer an interface to open a stream inside this connection and to receive incomming stream requests.
|
||||
|
||||
#### Dial(open/create) a new stream
|
||||
|
||||
```go
|
||||
stream, err := muxedConn.newStream()
|
||||
```
|
||||
|
||||
This method negotiates and opens a new stream with the other endpoint.
|
||||
|
||||
If `err` is passed, no operation should be made in `stream`.
|
||||
|
||||
`stream` interface our established Stream with the other endpoint, it must implement the [ReadWriteCloser](http://golang.org/pkg/io/#ReadWriteCloser).
|
||||
|
||||
#### Listen(wait/accept) a new incoming stream
|
||||
|
||||
```go
|
||||
stream := muxedConn.Accept()
|
||||
```
|
||||
|
||||
Each time a dialing peer initiates the new stream handshake, a new stream is created on the listening side.
|
||||
|
@ -1,63 +0,0 @@
|
||||
{
|
||||
"name": "interface-stream-muxer",
|
||||
"version": "0.8.0",
|
||||
"description": "A test suite and interface you can use to implement a stream muxer.",
|
||||
"leadMaintainer": "Jacob Heun <jacobheun@gmail.com>",
|
||||
"main": "src/index.js",
|
||||
"browser": {
|
||||
"libp2p-tcp": false
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node -e 'process.exit()'",
|
||||
"test:node": "node -e 'process.exit()'",
|
||||
"build": "aegir build -t node",
|
||||
"lint": "aegir lint",
|
||||
"release": "aegir release -t node",
|
||||
"release-minor": "aegir release -t node --type minor",
|
||||
"release-major": "aegir release -t node --type major",
|
||||
"coverage": "node -e 'process.exit()'",
|
||||
"coverage-publish": "node -e 'process.exit()'"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/libp2p/interface-stream-muxer.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Streams",
|
||||
"Muxer",
|
||||
"Interface"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/libp2p/interface-stream-muxer/issues"
|
||||
},
|
||||
"homepage": "https://github.com/libp2p/interface-stream-muxer",
|
||||
"dependencies": {
|
||||
"abort-controller": "^3.0.0",
|
||||
"abortable-iterator": "^2.1.0",
|
||||
"chai": "^4.2.0",
|
||||
"chai-checkmark": "^1.0.1",
|
||||
"detect-node": "^2.0.4",
|
||||
"it-pair": "^1.0.0",
|
||||
"it-pipe": "^1.0.1",
|
||||
"libp2p-tcp": "^0.14.0",
|
||||
"multiaddr": "^7.1.0",
|
||||
"p-limit": "^2.2.0",
|
||||
"streaming-iterables": "^4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"aegir": "^20.0.0"
|
||||
},
|
||||
"contributors": [
|
||||
"Alan Shaw <alan.shaw@protocol.ai>",
|
||||
"David Dias <daviddias.p@gmail.com>",
|
||||
"David Dias <mail@daviddias.me>",
|
||||
"Dmitriy Ryajov <dryajov@gmail.com>",
|
||||
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
|
||||
"Jacob Heun <jacobheun@gmail.com>",
|
||||
"Jeffrey Hulten <jhulten@gmail.com>",
|
||||
"Vasco Santos <vasco.santos@moxy.studio>",
|
||||
"greenkeeperio-bot <support@greenkeeper.io>",
|
||||
"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>"
|
||||
]
|
||||
}
|
@ -1 +0,0 @@
|
||||
'use strict'
|
Loading…
x
Reference in New Issue
Block a user