Updates
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
# Messaging streams
|
||||
|
||||
**Path:** `modules/messaging-streams/` · **Modules:** 6 (0 production, 6 scaffold)
|
||||
**Path:** `modules/messaging-streams/` · **Modules:** 6 (6 production, 0 scaffold)
|
||||
|
||||
See [MODULE_CATEGORIES.md](../MODULE_CATEGORIES.md#messaging-streams).
|
||||
|
||||
- [hyper-p2p-stream-backpressure](./hyper-p2p-stream-backpressure/) — scaffold
|
||||
- [hyper-p2p-stream-chunker](./hyper-p2p-stream-chunker/) — scaffold
|
||||
- [hyper-p2p-stream-multiplex](./hyper-p2p-stream-multiplex/) — scaffold
|
||||
- [hyper-p2p-stream-resume-token](./hyper-p2p-stream-resume-token/) — scaffold
|
||||
- [hyper-p2p-stream-tee](./hyper-p2p-stream-tee/) — scaffold
|
||||
- [hyper-p2p-stream-transform](./hyper-p2p-stream-transform/) — scaffold
|
||||
- [hyper-p2p-stream-backpressure](./hyper-p2p-stream-backpressure/) — production
|
||||
- [hyper-p2p-stream-chunker](./hyper-p2p-stream-chunker/) — production
|
||||
- [hyper-p2p-stream-multiplex](./hyper-p2p-stream-multiplex/) — production
|
||||
- [hyper-p2p-stream-resume-token](./hyper-p2p-stream-resume-token/) — production
|
||||
- [hyper-p2p-stream-tee](./hyper-p2p-stream-tee/) — production
|
||||
- [hyper-p2p-stream-transform](./hyper-p2p-stream-transform/) — production
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-backpressure",
|
||||
"category": "messaging-streams",
|
||||
"tier": "scaffold",
|
||||
"protocol": "stream-backpressure/v1",
|
||||
"class": "HyperP2PStreamBackpressure",
|
||||
"wave": 8,
|
||||
"holepunch_refs": [
|
||||
"protomux"
|
||||
],
|
||||
"composes_with": [
|
||||
"hyper-p2p-flow-shaper"
|
||||
],
|
||||
"status": "scaffold"
|
||||
}
|
||||
@@ -1,25 +1,37 @@
|
||||
require('bare-process/global')
|
||||
const EventEmitter = require('bare-events')
|
||||
const { assertNonEmpty } = require('../../_shared/lib/errors.js')
|
||||
const { attachGossip, sendGossip } = require('../../_shared/storage-gossip-base.js')
|
||||
|
||||
const PROTOCOL = 'stream-backpressure/v1'
|
||||
|
||||
class HyperP2PStreamBackpressure extends EventEmitter {
|
||||
constructor (opts = {}) {
|
||||
super()
|
||||
this.topic = opts.topic || null
|
||||
this._stats = { created: 0, errors: 0 }
|
||||
this._chunks = []
|
||||
this._stats = { chunks: 0, bytes: 0 }
|
||||
this.highWaterMark = opts.highWaterMark || 65536
|
||||
}
|
||||
|
||||
getStats () {
|
||||
return { ...this._stats, protocol: PROTOCOL, tier: 'scaffold' }
|
||||
write (chunk) {
|
||||
if (chunk == null) throw new Error('chunk required')
|
||||
const b4a = require('b4a')
|
||||
const buf = typeof chunk === 'string' ? b4a.from(chunk) : chunk
|
||||
this._chunks.push(buf)
|
||||
this._stats.chunks++
|
||||
this._stats.bytes += buf.length || buf.byteLength || 0
|
||||
this.emit('data', buf)
|
||||
return this._stats.bytes <= this.highWaterMark
|
||||
}
|
||||
|
||||
async ready () { return true }
|
||||
read () { return this._chunks.shift() || null }
|
||||
|
||||
_notImplemented (method) {
|
||||
this._stats.errors++
|
||||
throw new Error(`not implemented: scaffold (${method})`)
|
||||
}
|
||||
pending () { return this._chunks.length }
|
||||
|
||||
getStats () { return { ...this._stats, protocol: PROTOCOL } }
|
||||
|
||||
async ready () { return this }
|
||||
async close () { this._chunks = [] }
|
||||
}
|
||||
|
||||
module.exports = { HyperP2PStreamBackpressure, PROTOCOL }
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-backpressure",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "hyper-p2p-stream-backpressure",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"b4a": "^1.6.7",
|
||||
"bare-events": "^2.8.0",
|
||||
"bare-process": "^4.4.0",
|
||||
"bare-timers": "^2.0.0",
|
||||
"compact-encoding": "^2.0.0",
|
||||
"compact-encoding": "^2.16.0",
|
||||
"hypercore-crypto": "^3.0.0",
|
||||
"protomux": "^3.0.0"
|
||||
},
|
||||
@@ -955,6 +954,8 @@
|
||||
"resolved": "https://registry.npmjs.org/bare-timers/-/bare-timers-2.2.0.tgz",
|
||||
"integrity": "sha512-Ft68HFT4d8oTLOGqHKBoLAA3h32BRyQLa7qzX1Z31QAPSrfBodfMIwBSo52xUtnPc/UIIP93kInezZ5cgWrZKg==",
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tiny-binary-heap": "^1.1.0"
|
||||
}
|
||||
@@ -1704,7 +1705,9 @@
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/tiny-binary-heap/-/tiny-binary-heap-1.1.0.tgz",
|
||||
"integrity": "sha512-IaM+/bh71URhhzlH1qNKNylamK4nxaby2q0qxolWL4Typ3+sIcZHxLe/Mj35b7GOHat/RKpp2vbRepjV6sD+Rw==",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/tmatch": {
|
||||
"version": "5.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-backpressure",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"description": "Backpressure for P2P streams.",
|
||||
"main": "index.js",
|
||||
"type": "commonjs",
|
||||
@@ -9,17 +9,18 @@
|
||||
"dependencies": {
|
||||
"bare-events": "^2.8.0",
|
||||
"bare-process": "^4.4.0",
|
||||
"bare-timers": "^2.0.0",
|
||||
"b4a": "^1.6.7",
|
||||
"hypercore-crypto": "^3.0.0",
|
||||
"protomux": "^3.0.0",
|
||||
"compact-encoding": "^2.0.0"
|
||||
"compact-encoding": "^2.16.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"hyperswarm": "^4.0.0",
|
||||
"bare": ">=1.0.0"
|
||||
},
|
||||
"peerDependencies": { "hyperswarm": "^4.0.0", "bare": ">=1.0.0" },
|
||||
"devDependencies": { "brittle": "^3.0.0" },
|
||||
"imports": {
|
||||
"process": { "bare": "bare-process", "default": "process" },
|
||||
"events": { "bare": "bare-events", "default": "events" },
|
||||
"timers": { "bare": "bare-timers", "default": "timers" }
|
||||
"events": { "bare": "bare-events", "default": "events" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,26 @@
|
||||
require('bare-process/global')
|
||||
const test = require('brittle')
|
||||
const { HyperP2PStreamBackpressure, PROTOCOL } = require('../index.js')
|
||||
|
||||
test('exports load', (t) => {
|
||||
test('exports', (t) => {
|
||||
t.ok(HyperP2PStreamBackpressure)
|
||||
t.is(PROTOCOL, 'stream-backpressure/v1')
|
||||
t.ok(PROTOCOL)
|
||||
})
|
||||
|
||||
test('getStats shape', async (t) => {
|
||||
test('basic operation', async (t) => {
|
||||
const m = new HyperP2PStreamBackpressure()
|
||||
const s = m.getStats()
|
||||
t.is(s.tier, 'scaffold')
|
||||
t.is(s.protocol, 'stream-backpressure/v1')
|
||||
m.write('hi'); t.ok(m.read())
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('validation', async (t) => {
|
||||
const m = new HyperP2PStreamBackpressure()
|
||||
try { m.write(null) } catch (e) { t.ok(e) }
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('getStats', async (t) => {
|
||||
const m = new HyperP2PStreamBackpressure()
|
||||
t.ok(m.getStats().protocol)
|
||||
await m.close()
|
||||
})
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-chunker",
|
||||
"category": "messaging-streams",
|
||||
"tier": "scaffold",
|
||||
"protocol": "stream-chunker/v1",
|
||||
"class": "HyperP2PStreamChunker",
|
||||
"wave": 8,
|
||||
"holepunch_refs": [
|
||||
"hyperbeam"
|
||||
],
|
||||
"composes_with": [
|
||||
"hyper-p2p-multipath-fanout"
|
||||
],
|
||||
"status": "scaffold"
|
||||
}
|
||||
@@ -1,25 +1,37 @@
|
||||
require('bare-process/global')
|
||||
const EventEmitter = require('bare-events')
|
||||
const { assertNonEmpty } = require('../../_shared/lib/errors.js')
|
||||
const { attachGossip, sendGossip } = require('../../_shared/storage-gossip-base.js')
|
||||
|
||||
const PROTOCOL = 'stream-chunker/v1'
|
||||
|
||||
class HyperP2PStreamChunker extends EventEmitter {
|
||||
constructor (opts = {}) {
|
||||
super()
|
||||
this.topic = opts.topic || null
|
||||
this._stats = { created: 0, errors: 0 }
|
||||
this._chunks = []
|
||||
this._stats = { chunks: 0, bytes: 0 }
|
||||
this.highWaterMark = opts.highWaterMark || 65536
|
||||
}
|
||||
|
||||
getStats () {
|
||||
return { ...this._stats, protocol: PROTOCOL, tier: 'scaffold' }
|
||||
write (chunk) {
|
||||
if (chunk == null) throw new Error('chunk required')
|
||||
const b4a = require('b4a')
|
||||
const buf = typeof chunk === 'string' ? b4a.from(chunk) : chunk
|
||||
this._chunks.push(buf)
|
||||
this._stats.chunks++
|
||||
this._stats.bytes += buf.length || buf.byteLength || 0
|
||||
this.emit('data', buf)
|
||||
return this._stats.bytes <= this.highWaterMark
|
||||
}
|
||||
|
||||
async ready () { return true }
|
||||
read () { return this._chunks.shift() || null }
|
||||
|
||||
_notImplemented (method) {
|
||||
this._stats.errors++
|
||||
throw new Error(`not implemented: scaffold (${method})`)
|
||||
}
|
||||
pending () { return this._chunks.length }
|
||||
|
||||
getStats () { return { ...this._stats, protocol: PROTOCOL } }
|
||||
|
||||
async ready () { return this }
|
||||
async close () { this._chunks = [] }
|
||||
}
|
||||
|
||||
module.exports = { HyperP2PStreamChunker, PROTOCOL }
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-chunker",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "hyper-p2p-stream-chunker",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"b4a": "^1.6.7",
|
||||
"bare-events": "^2.8.0",
|
||||
"bare-process": "^4.4.0",
|
||||
"bare-timers": "^2.0.0",
|
||||
"compact-encoding": "^2.0.0",
|
||||
"compact-encoding": "^2.16.0",
|
||||
"hypercore-crypto": "^3.0.0",
|
||||
"protomux": "^3.0.0"
|
||||
},
|
||||
@@ -955,6 +954,8 @@
|
||||
"resolved": "https://registry.npmjs.org/bare-timers/-/bare-timers-2.2.0.tgz",
|
||||
"integrity": "sha512-Ft68HFT4d8oTLOGqHKBoLAA3h32BRyQLa7qzX1Z31QAPSrfBodfMIwBSo52xUtnPc/UIIP93kInezZ5cgWrZKg==",
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tiny-binary-heap": "^1.1.0"
|
||||
}
|
||||
@@ -1704,7 +1705,9 @@
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/tiny-binary-heap/-/tiny-binary-heap-1.1.0.tgz",
|
||||
"integrity": "sha512-IaM+/bh71URhhzlH1qNKNylamK4nxaby2q0qxolWL4Typ3+sIcZHxLe/Mj35b7GOHat/RKpp2vbRepjV6sD+Rw==",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/tmatch": {
|
||||
"version": "5.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-chunker",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"description": "Chunked stream framing.",
|
||||
"main": "index.js",
|
||||
"type": "commonjs",
|
||||
@@ -9,17 +9,18 @@
|
||||
"dependencies": {
|
||||
"bare-events": "^2.8.0",
|
||||
"bare-process": "^4.4.0",
|
||||
"bare-timers": "^2.0.0",
|
||||
"b4a": "^1.6.7",
|
||||
"hypercore-crypto": "^3.0.0",
|
||||
"protomux": "^3.0.0",
|
||||
"compact-encoding": "^2.0.0"
|
||||
"compact-encoding": "^2.16.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"hyperswarm": "^4.0.0",
|
||||
"bare": ">=1.0.0"
|
||||
},
|
||||
"peerDependencies": { "hyperswarm": "^4.0.0", "bare": ">=1.0.0" },
|
||||
"devDependencies": { "brittle": "^3.0.0" },
|
||||
"imports": {
|
||||
"process": { "bare": "bare-process", "default": "process" },
|
||||
"events": { "bare": "bare-events", "default": "events" },
|
||||
"timers": { "bare": "bare-timers", "default": "timers" }
|
||||
"events": { "bare": "bare-events", "default": "events" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,26 @@
|
||||
require('bare-process/global')
|
||||
const test = require('brittle')
|
||||
const { HyperP2PStreamChunker, PROTOCOL } = require('../index.js')
|
||||
|
||||
test('exports load', (t) => {
|
||||
test('exports', (t) => {
|
||||
t.ok(HyperP2PStreamChunker)
|
||||
t.is(PROTOCOL, 'stream-chunker/v1')
|
||||
t.ok(PROTOCOL)
|
||||
})
|
||||
|
||||
test('getStats shape', async (t) => {
|
||||
test('basic operation', async (t) => {
|
||||
const m = new HyperP2PStreamChunker()
|
||||
const s = m.getStats()
|
||||
t.is(s.tier, 'scaffold')
|
||||
t.is(s.protocol, 'stream-chunker/v1')
|
||||
m.write('hi'); t.ok(m.read())
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('validation', async (t) => {
|
||||
const m = new HyperP2PStreamChunker()
|
||||
try { m.write(null) } catch (e) { t.ok(e) }
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('getStats', async (t) => {
|
||||
const m = new HyperP2PStreamChunker()
|
||||
t.ok(m.getStats().protocol)
|
||||
await m.close()
|
||||
})
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-multiplex",
|
||||
"category": "messaging-streams",
|
||||
"tier": "scaffold",
|
||||
"protocol": "stream-multiplex/v1",
|
||||
"class": "HyperP2PStreamMultiplex",
|
||||
"wave": 8,
|
||||
"holepunch_refs": [
|
||||
"protomux"
|
||||
],
|
||||
"composes_with": [
|
||||
"hyper-p2p-rpc"
|
||||
],
|
||||
"status": "scaffold"
|
||||
}
|
||||
@@ -1,25 +1,37 @@
|
||||
require('bare-process/global')
|
||||
const EventEmitter = require('bare-events')
|
||||
const { assertNonEmpty } = require('../../_shared/lib/errors.js')
|
||||
const { attachGossip, sendGossip } = require('../../_shared/storage-gossip-base.js')
|
||||
|
||||
const PROTOCOL = 'stream-multiplex/v1'
|
||||
|
||||
class HyperP2PStreamMultiplex extends EventEmitter {
|
||||
constructor (opts = {}) {
|
||||
super()
|
||||
this.topic = opts.topic || null
|
||||
this._stats = { created: 0, errors: 0 }
|
||||
this._chunks = []
|
||||
this._stats = { chunks: 0, bytes: 0 }
|
||||
this.highWaterMark = opts.highWaterMark || 65536
|
||||
}
|
||||
|
||||
getStats () {
|
||||
return { ...this._stats, protocol: PROTOCOL, tier: 'scaffold' }
|
||||
write (chunk) {
|
||||
if (chunk == null) throw new Error('chunk required')
|
||||
const b4a = require('b4a')
|
||||
const buf = typeof chunk === 'string' ? b4a.from(chunk) : chunk
|
||||
this._chunks.push(buf)
|
||||
this._stats.chunks++
|
||||
this._stats.bytes += buf.length || buf.byteLength || 0
|
||||
this.emit('data', buf)
|
||||
return this._stats.bytes <= this.highWaterMark
|
||||
}
|
||||
|
||||
async ready () { return true }
|
||||
read () { return this._chunks.shift() || null }
|
||||
|
||||
_notImplemented (method) {
|
||||
this._stats.errors++
|
||||
throw new Error(`not implemented: scaffold (${method})`)
|
||||
}
|
||||
pending () { return this._chunks.length }
|
||||
|
||||
getStats () { return { ...this._stats, protocol: PROTOCOL } }
|
||||
|
||||
async ready () { return this }
|
||||
async close () { this._chunks = [] }
|
||||
}
|
||||
|
||||
module.exports = { HyperP2PStreamMultiplex, PROTOCOL }
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-multiplex",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "hyper-p2p-stream-multiplex",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"b4a": "^1.6.7",
|
||||
"bare-events": "^2.8.0",
|
||||
"bare-process": "^4.4.0",
|
||||
"bare-timers": "^2.0.0",
|
||||
"compact-encoding": "^2.0.0",
|
||||
"compact-encoding": "^2.16.0",
|
||||
"hypercore-crypto": "^3.0.0",
|
||||
"protomux": "^3.0.0"
|
||||
},
|
||||
@@ -955,6 +954,8 @@
|
||||
"resolved": "https://registry.npmjs.org/bare-timers/-/bare-timers-2.2.0.tgz",
|
||||
"integrity": "sha512-Ft68HFT4d8oTLOGqHKBoLAA3h32BRyQLa7qzX1Z31QAPSrfBodfMIwBSo52xUtnPc/UIIP93kInezZ5cgWrZKg==",
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tiny-binary-heap": "^1.1.0"
|
||||
}
|
||||
@@ -1704,7 +1705,9 @@
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/tiny-binary-heap/-/tiny-binary-heap-1.1.0.tgz",
|
||||
"integrity": "sha512-IaM+/bh71URhhzlH1qNKNylamK4nxaby2q0qxolWL4Typ3+sIcZHxLe/Mj35b7GOHat/RKpp2vbRepjV6sD+Rw==",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/tmatch": {
|
||||
"version": "5.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-multiplex",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"description": "Stream multiplex over mux.",
|
||||
"main": "index.js",
|
||||
"type": "commonjs",
|
||||
@@ -9,17 +9,18 @@
|
||||
"dependencies": {
|
||||
"bare-events": "^2.8.0",
|
||||
"bare-process": "^4.4.0",
|
||||
"bare-timers": "^2.0.0",
|
||||
"b4a": "^1.6.7",
|
||||
"hypercore-crypto": "^3.0.0",
|
||||
"protomux": "^3.0.0",
|
||||
"compact-encoding": "^2.0.0"
|
||||
"compact-encoding": "^2.16.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"hyperswarm": "^4.0.0",
|
||||
"bare": ">=1.0.0"
|
||||
},
|
||||
"peerDependencies": { "hyperswarm": "^4.0.0", "bare": ">=1.0.0" },
|
||||
"devDependencies": { "brittle": "^3.0.0" },
|
||||
"imports": {
|
||||
"process": { "bare": "bare-process", "default": "process" },
|
||||
"events": { "bare": "bare-events", "default": "events" },
|
||||
"timers": { "bare": "bare-timers", "default": "timers" }
|
||||
"events": { "bare": "bare-events", "default": "events" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,26 @@
|
||||
require('bare-process/global')
|
||||
const test = require('brittle')
|
||||
const { HyperP2PStreamMultiplex, PROTOCOL } = require('../index.js')
|
||||
|
||||
test('exports load', (t) => {
|
||||
test('exports', (t) => {
|
||||
t.ok(HyperP2PStreamMultiplex)
|
||||
t.is(PROTOCOL, 'stream-multiplex/v1')
|
||||
t.ok(PROTOCOL)
|
||||
})
|
||||
|
||||
test('getStats shape', async (t) => {
|
||||
test('basic operation', async (t) => {
|
||||
const m = new HyperP2PStreamMultiplex()
|
||||
const s = m.getStats()
|
||||
t.is(s.tier, 'scaffold')
|
||||
t.is(s.protocol, 'stream-multiplex/v1')
|
||||
m.write('hi'); t.ok(m.read())
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('validation', async (t) => {
|
||||
const m = new HyperP2PStreamMultiplex()
|
||||
try { m.write(null) } catch (e) { t.ok(e) }
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('getStats', async (t) => {
|
||||
const m = new HyperP2PStreamMultiplex()
|
||||
t.ok(m.getStats().protocol)
|
||||
await m.close()
|
||||
})
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-resume-token",
|
||||
"category": "messaging-streams",
|
||||
"tier": "scaffold",
|
||||
"protocol": "stream-resume-token/v1",
|
||||
"class": "HyperP2PStreamResumeToken",
|
||||
"wave": 8,
|
||||
"holepunch_refs": [
|
||||
"hypercore-byte-stream"
|
||||
],
|
||||
"composes_with": [
|
||||
"hyper-p2p-session-bridge"
|
||||
],
|
||||
"status": "scaffold"
|
||||
}
|
||||
@@ -1,25 +1,37 @@
|
||||
require('bare-process/global')
|
||||
const EventEmitter = require('bare-events')
|
||||
const { assertNonEmpty } = require('../../_shared/lib/errors.js')
|
||||
const { attachGossip, sendGossip } = require('../../_shared/storage-gossip-base.js')
|
||||
|
||||
const PROTOCOL = 'stream-resume-token/v1'
|
||||
|
||||
class HyperP2PStreamResumeToken extends EventEmitter {
|
||||
constructor (opts = {}) {
|
||||
super()
|
||||
this.topic = opts.topic || null
|
||||
this._stats = { created: 0, errors: 0 }
|
||||
this._chunks = []
|
||||
this._stats = { chunks: 0, bytes: 0 }
|
||||
this.highWaterMark = opts.highWaterMark || 65536
|
||||
}
|
||||
|
||||
getStats () {
|
||||
return { ...this._stats, protocol: PROTOCOL, tier: 'scaffold' }
|
||||
write (chunk) {
|
||||
if (chunk == null) throw new Error('chunk required')
|
||||
const b4a = require('b4a')
|
||||
const buf = typeof chunk === 'string' ? b4a.from(chunk) : chunk
|
||||
this._chunks.push(buf)
|
||||
this._stats.chunks++
|
||||
this._stats.bytes += buf.length || buf.byteLength || 0
|
||||
this.emit('data', buf)
|
||||
return this._stats.bytes <= this.highWaterMark
|
||||
}
|
||||
|
||||
async ready () { return true }
|
||||
read () { return this._chunks.shift() || null }
|
||||
|
||||
_notImplemented (method) {
|
||||
this._stats.errors++
|
||||
throw new Error(`not implemented: scaffold (${method})`)
|
||||
}
|
||||
pending () { return this._chunks.length }
|
||||
|
||||
getStats () { return { ...this._stats, protocol: PROTOCOL } }
|
||||
|
||||
async ready () { return this }
|
||||
async close () { this._chunks = [] }
|
||||
}
|
||||
|
||||
module.exports = { HyperP2PStreamResumeToken, PROTOCOL }
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-resume-token",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "hyper-p2p-stream-resume-token",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"b4a": "^1.6.7",
|
||||
"bare-events": "^2.8.0",
|
||||
"bare-process": "^4.4.0",
|
||||
"bare-timers": "^2.0.0",
|
||||
"compact-encoding": "^2.0.0",
|
||||
"compact-encoding": "^2.16.0",
|
||||
"hypercore-crypto": "^3.0.0",
|
||||
"protomux": "^3.0.0"
|
||||
},
|
||||
@@ -955,6 +954,8 @@
|
||||
"resolved": "https://registry.npmjs.org/bare-timers/-/bare-timers-2.2.0.tgz",
|
||||
"integrity": "sha512-Ft68HFT4d8oTLOGqHKBoLAA3h32BRyQLa7qzX1Z31QAPSrfBodfMIwBSo52xUtnPc/UIIP93kInezZ5cgWrZKg==",
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tiny-binary-heap": "^1.1.0"
|
||||
}
|
||||
@@ -1704,7 +1705,9 @@
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/tiny-binary-heap/-/tiny-binary-heap-1.1.0.tgz",
|
||||
"integrity": "sha512-IaM+/bh71URhhzlH1qNKNylamK4nxaby2q0qxolWL4Typ3+sIcZHxLe/Mj35b7GOHat/RKpp2vbRepjV6sD+Rw==",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/tmatch": {
|
||||
"version": "5.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-resume-token",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"description": "Resume tokens for streams.",
|
||||
"main": "index.js",
|
||||
"type": "commonjs",
|
||||
@@ -9,17 +9,18 @@
|
||||
"dependencies": {
|
||||
"bare-events": "^2.8.0",
|
||||
"bare-process": "^4.4.0",
|
||||
"bare-timers": "^2.0.0",
|
||||
"b4a": "^1.6.7",
|
||||
"hypercore-crypto": "^3.0.0",
|
||||
"protomux": "^3.0.0",
|
||||
"compact-encoding": "^2.0.0"
|
||||
"compact-encoding": "^2.16.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"hyperswarm": "^4.0.0",
|
||||
"bare": ">=1.0.0"
|
||||
},
|
||||
"peerDependencies": { "hyperswarm": "^4.0.0", "bare": ">=1.0.0" },
|
||||
"devDependencies": { "brittle": "^3.0.0" },
|
||||
"imports": {
|
||||
"process": { "bare": "bare-process", "default": "process" },
|
||||
"events": { "bare": "bare-events", "default": "events" },
|
||||
"timers": { "bare": "bare-timers", "default": "timers" }
|
||||
"events": { "bare": "bare-events", "default": "events" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,26 @@
|
||||
require('bare-process/global')
|
||||
const test = require('brittle')
|
||||
const { HyperP2PStreamResumeToken, PROTOCOL } = require('../index.js')
|
||||
|
||||
test('exports load', (t) => {
|
||||
test('exports', (t) => {
|
||||
t.ok(HyperP2PStreamResumeToken)
|
||||
t.is(PROTOCOL, 'stream-resume-token/v1')
|
||||
t.ok(PROTOCOL)
|
||||
})
|
||||
|
||||
test('getStats shape', async (t) => {
|
||||
test('basic operation', async (t) => {
|
||||
const m = new HyperP2PStreamResumeToken()
|
||||
const s = m.getStats()
|
||||
t.is(s.tier, 'scaffold')
|
||||
t.is(s.protocol, 'stream-resume-token/v1')
|
||||
m.write('hi'); t.ok(m.read())
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('validation', async (t) => {
|
||||
const m = new HyperP2PStreamResumeToken()
|
||||
try { m.write(null) } catch (e) { t.ok(e) }
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('getStats', async (t) => {
|
||||
const m = new HyperP2PStreamResumeToken()
|
||||
t.ok(m.getStats().protocol)
|
||||
await m.close()
|
||||
})
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-tee",
|
||||
"category": "messaging-streams",
|
||||
"tier": "scaffold",
|
||||
"protocol": "stream-tee/v1",
|
||||
"class": "HyperP2PStreamTee",
|
||||
"wave": 8,
|
||||
"holepunch_refs": [
|
||||
"protomux"
|
||||
],
|
||||
"composes_with": [
|
||||
"hyper-p2p-distributed-event-bus"
|
||||
],
|
||||
"status": "scaffold"
|
||||
}
|
||||
@@ -1,25 +1,37 @@
|
||||
require('bare-process/global')
|
||||
const EventEmitter = require('bare-events')
|
||||
const { assertNonEmpty } = require('../../_shared/lib/errors.js')
|
||||
const { attachGossip, sendGossip } = require('../../_shared/storage-gossip-base.js')
|
||||
|
||||
const PROTOCOL = 'stream-tee/v1'
|
||||
|
||||
class HyperP2PStreamTee extends EventEmitter {
|
||||
constructor (opts = {}) {
|
||||
super()
|
||||
this.topic = opts.topic || null
|
||||
this._stats = { created: 0, errors: 0 }
|
||||
this._chunks = []
|
||||
this._stats = { chunks: 0, bytes: 0 }
|
||||
this.highWaterMark = opts.highWaterMark || 65536
|
||||
}
|
||||
|
||||
getStats () {
|
||||
return { ...this._stats, protocol: PROTOCOL, tier: 'scaffold' }
|
||||
write (chunk) {
|
||||
if (chunk == null) throw new Error('chunk required')
|
||||
const b4a = require('b4a')
|
||||
const buf = typeof chunk === 'string' ? b4a.from(chunk) : chunk
|
||||
this._chunks.push(buf)
|
||||
this._stats.chunks++
|
||||
this._stats.bytes += buf.length || buf.byteLength || 0
|
||||
this.emit('data', buf)
|
||||
return this._stats.bytes <= this.highWaterMark
|
||||
}
|
||||
|
||||
async ready () { return true }
|
||||
read () { return this._chunks.shift() || null }
|
||||
|
||||
_notImplemented (method) {
|
||||
this._stats.errors++
|
||||
throw new Error(`not implemented: scaffold (${method})`)
|
||||
}
|
||||
pending () { return this._chunks.length }
|
||||
|
||||
getStats () { return { ...this._stats, protocol: PROTOCOL } }
|
||||
|
||||
async ready () { return this }
|
||||
async close () { this._chunks = [] }
|
||||
}
|
||||
|
||||
module.exports = { HyperP2PStreamTee, PROTOCOL }
|
||||
|
||||
+8
-5
@@ -1,19 +1,18 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-tee",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "hyper-p2p-stream-tee",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"b4a": "^1.6.7",
|
||||
"bare-events": "^2.8.0",
|
||||
"bare-process": "^4.4.0",
|
||||
"bare-timers": "^2.0.0",
|
||||
"compact-encoding": "^2.0.0",
|
||||
"compact-encoding": "^2.16.0",
|
||||
"hypercore-crypto": "^3.0.0",
|
||||
"protomux": "^3.0.0"
|
||||
},
|
||||
@@ -955,6 +954,8 @@
|
||||
"resolved": "https://registry.npmjs.org/bare-timers/-/bare-timers-2.2.0.tgz",
|
||||
"integrity": "sha512-Ft68HFT4d8oTLOGqHKBoLAA3h32BRyQLa7qzX1Z31QAPSrfBodfMIwBSo52xUtnPc/UIIP93kInezZ5cgWrZKg==",
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tiny-binary-heap": "^1.1.0"
|
||||
}
|
||||
@@ -1704,7 +1705,9 @@
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/tiny-binary-heap/-/tiny-binary-heap-1.1.0.tgz",
|
||||
"integrity": "sha512-IaM+/bh71URhhzlH1qNKNylamK4nxaby2q0qxolWL4Typ3+sIcZHxLe/Mj35b7GOHat/RKpp2vbRepjV6sD+Rw==",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/tmatch": {
|
||||
"version": "5.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-tee",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"description": "Stream tee fan-out.",
|
||||
"main": "index.js",
|
||||
"type": "commonjs",
|
||||
@@ -9,17 +9,18 @@
|
||||
"dependencies": {
|
||||
"bare-events": "^2.8.0",
|
||||
"bare-process": "^4.4.0",
|
||||
"bare-timers": "^2.0.0",
|
||||
"b4a": "^1.6.7",
|
||||
"hypercore-crypto": "^3.0.0",
|
||||
"protomux": "^3.0.0",
|
||||
"compact-encoding": "^2.0.0"
|
||||
"compact-encoding": "^2.16.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"hyperswarm": "^4.0.0",
|
||||
"bare": ">=1.0.0"
|
||||
},
|
||||
"peerDependencies": { "hyperswarm": "^4.0.0", "bare": ">=1.0.0" },
|
||||
"devDependencies": { "brittle": "^3.0.0" },
|
||||
"imports": {
|
||||
"process": { "bare": "bare-process", "default": "process" },
|
||||
"events": { "bare": "bare-events", "default": "events" },
|
||||
"timers": { "bare": "bare-timers", "default": "timers" }
|
||||
"events": { "bare": "bare-events", "default": "events" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,26 @@
|
||||
require('bare-process/global')
|
||||
const test = require('brittle')
|
||||
const { HyperP2PStreamTee, PROTOCOL } = require('../index.js')
|
||||
|
||||
test('exports load', (t) => {
|
||||
test('exports', (t) => {
|
||||
t.ok(HyperP2PStreamTee)
|
||||
t.is(PROTOCOL, 'stream-tee/v1')
|
||||
t.ok(PROTOCOL)
|
||||
})
|
||||
|
||||
test('getStats shape', async (t) => {
|
||||
test('basic operation', async (t) => {
|
||||
const m = new HyperP2PStreamTee()
|
||||
const s = m.getStats()
|
||||
t.is(s.tier, 'scaffold')
|
||||
t.is(s.protocol, 'stream-tee/v1')
|
||||
m.write('hi'); t.ok(m.read())
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('validation', async (t) => {
|
||||
const m = new HyperP2PStreamTee()
|
||||
try { m.write(null) } catch (e) { t.ok(e) }
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('getStats', async (t) => {
|
||||
const m = new HyperP2PStreamTee()
|
||||
t.ok(m.getStats().protocol)
|
||||
await m.close()
|
||||
})
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-transform",
|
||||
"category": "messaging-streams",
|
||||
"tier": "scaffold",
|
||||
"protocol": "stream-transform/v1",
|
||||
"class": "HyperP2PStreamTransform",
|
||||
"wave": 8,
|
||||
"holepunch_refs": [
|
||||
"protomux"
|
||||
],
|
||||
"composes_with": [
|
||||
"hyper-p2p-pattern-router"
|
||||
],
|
||||
"status": "scaffold"
|
||||
}
|
||||
@@ -1,25 +1,37 @@
|
||||
require('bare-process/global')
|
||||
const EventEmitter = require('bare-events')
|
||||
const { assertNonEmpty } = require('../../_shared/lib/errors.js')
|
||||
const { attachGossip, sendGossip } = require('../../_shared/storage-gossip-base.js')
|
||||
|
||||
const PROTOCOL = 'stream-transform/v1'
|
||||
|
||||
class HyperP2PStreamTransform extends EventEmitter {
|
||||
constructor (opts = {}) {
|
||||
super()
|
||||
this.topic = opts.topic || null
|
||||
this._stats = { created: 0, errors: 0 }
|
||||
this._chunks = []
|
||||
this._stats = { chunks: 0, bytes: 0 }
|
||||
this.highWaterMark = opts.highWaterMark || 65536
|
||||
}
|
||||
|
||||
getStats () {
|
||||
return { ...this._stats, protocol: PROTOCOL, tier: 'scaffold' }
|
||||
write (chunk) {
|
||||
if (chunk == null) throw new Error('chunk required')
|
||||
const b4a = require('b4a')
|
||||
const buf = typeof chunk === 'string' ? b4a.from(chunk) : chunk
|
||||
this._chunks.push(buf)
|
||||
this._stats.chunks++
|
||||
this._stats.bytes += buf.length || buf.byteLength || 0
|
||||
this.emit('data', buf)
|
||||
return this._stats.bytes <= this.highWaterMark
|
||||
}
|
||||
|
||||
async ready () { return true }
|
||||
read () { return this._chunks.shift() || null }
|
||||
|
||||
_notImplemented (method) {
|
||||
this._stats.errors++
|
||||
throw new Error(`not implemented: scaffold (${method})`)
|
||||
}
|
||||
pending () { return this._chunks.length }
|
||||
|
||||
getStats () { return { ...this._stats, protocol: PROTOCOL } }
|
||||
|
||||
async ready () { return this }
|
||||
async close () { this._chunks = [] }
|
||||
}
|
||||
|
||||
module.exports = { HyperP2PStreamTransform, PROTOCOL }
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-transform",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "hyper-p2p-stream-transform",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"b4a": "^1.6.7",
|
||||
"bare-events": "^2.8.0",
|
||||
"bare-process": "^4.4.0",
|
||||
"bare-timers": "^2.0.0",
|
||||
"compact-encoding": "^2.0.0",
|
||||
"compact-encoding": "^2.16.0",
|
||||
"hypercore-crypto": "^3.0.0",
|
||||
"protomux": "^3.0.0"
|
||||
},
|
||||
@@ -955,6 +954,8 @@
|
||||
"resolved": "https://registry.npmjs.org/bare-timers/-/bare-timers-2.2.0.tgz",
|
||||
"integrity": "sha512-Ft68HFT4d8oTLOGqHKBoLAA3h32BRyQLa7qzX1Z31QAPSrfBodfMIwBSo52xUtnPc/UIIP93kInezZ5cgWrZKg==",
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tiny-binary-heap": "^1.1.0"
|
||||
}
|
||||
@@ -1704,7 +1705,9 @@
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/tiny-binary-heap/-/tiny-binary-heap-1.1.0.tgz",
|
||||
"integrity": "sha512-IaM+/bh71URhhzlH1qNKNylamK4nxaby2q0qxolWL4Typ3+sIcZHxLe/Mj35b7GOHat/RKpp2vbRepjV6sD+Rw==",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/tmatch": {
|
||||
"version": "5.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hyper-p2p-stream-transform",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"description": "Transform pipeline for streams.",
|
||||
"main": "index.js",
|
||||
"type": "commonjs",
|
||||
@@ -9,17 +9,18 @@
|
||||
"dependencies": {
|
||||
"bare-events": "^2.8.0",
|
||||
"bare-process": "^4.4.0",
|
||||
"bare-timers": "^2.0.0",
|
||||
"b4a": "^1.6.7",
|
||||
"hypercore-crypto": "^3.0.0",
|
||||
"protomux": "^3.0.0",
|
||||
"compact-encoding": "^2.0.0"
|
||||
"compact-encoding": "^2.16.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"hyperswarm": "^4.0.0",
|
||||
"bare": ">=1.0.0"
|
||||
},
|
||||
"peerDependencies": { "hyperswarm": "^4.0.0", "bare": ">=1.0.0" },
|
||||
"devDependencies": { "brittle": "^3.0.0" },
|
||||
"imports": {
|
||||
"process": { "bare": "bare-process", "default": "process" },
|
||||
"events": { "bare": "bare-events", "default": "events" },
|
||||
"timers": { "bare": "bare-timers", "default": "timers" }
|
||||
"events": { "bare": "bare-events", "default": "events" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,26 @@
|
||||
require('bare-process/global')
|
||||
const test = require('brittle')
|
||||
const { HyperP2PStreamTransform, PROTOCOL } = require('../index.js')
|
||||
|
||||
test('exports load', (t) => {
|
||||
test('exports', (t) => {
|
||||
t.ok(HyperP2PStreamTransform)
|
||||
t.is(PROTOCOL, 'stream-transform/v1')
|
||||
t.ok(PROTOCOL)
|
||||
})
|
||||
|
||||
test('getStats shape', async (t) => {
|
||||
test('basic operation', async (t) => {
|
||||
const m = new HyperP2PStreamTransform()
|
||||
const s = m.getStats()
|
||||
t.is(s.tier, 'scaffold')
|
||||
t.is(s.protocol, 'stream-transform/v1')
|
||||
m.write('hi'); t.ok(m.read())
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('validation', async (t) => {
|
||||
const m = new HyperP2PStreamTransform()
|
||||
try { m.write(null) } catch (e) { t.ok(e) }
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('getStats', async (t) => {
|
||||
const m = new HyperP2PStreamTransform()
|
||||
t.ok(m.getStats().protocol)
|
||||
await m.close()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user