Expand media, agents, applications, and messaging module APIs on main.
Adds snapshot(), batch helpers, and clearAll aliases across media-streaming (20), agents-workflows, applications-collab/economy, messaging pubsub/streams/gossip. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -442,6 +442,14 @@ class HyperP2PAgentMemory extends EventEmitter {
|
|||||||
return [...this.memories.keys()]
|
return [...this.memories.keys()]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearAll () {
|
||||||
|
return this.clearAllMemories()
|
||||||
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { memories: this.memories.size, tags: this.tagIndex.size }
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return {
|
return {
|
||||||
...this._metrics,
|
...this._metrics,
|
||||||
|
|||||||
@@ -451,6 +451,10 @@ class HyperP2PTaskOrchestrator extends EventEmitter {
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { tasks: this.taskCounts() }
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
const counts = this.taskCounts()
|
const counts = this.taskCounts()
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -185,6 +185,10 @@ class HyperP2PWorkflowGraph extends EventEmitter {
|
|||||||
return this.clearGraph()
|
return this.clearGraph()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { nodes: this.nodeIds().length, edges: this._edges.length, pending: this.pendingCount() }
|
||||||
|
}
|
||||||
|
|
||||||
nodeIds () {
|
nodeIds () {
|
||||||
return [...this._nodes.keys()]
|
return [...this._nodes.keys()]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,6 +160,10 @@ class HyperP2PCollabRoom extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { rooms: this.listRooms(), count: this._rooms.size }
|
||||||
|
}
|
||||||
|
|
||||||
_onGossip (data) {
|
_onGossip (data) {
|
||||||
if (!data || !data.type) return
|
if (!data || !data.type) return
|
||||||
this._stats.gossipIn++
|
this._stats.gossipIn++
|
||||||
|
|||||||
@@ -106,6 +106,10 @@ class HyperP2PCursorPresence extends EventEmitter {
|
|||||||
return entries.map((e) => this.updateCursor(e.docId, e.position))
|
return entries.map((e) => this.updateCursor(e.docId, e.position))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { cursors: this._cursors.size, docs: this.listDocIds() }
|
||||||
|
}
|
||||||
|
|
||||||
_onGossip (data) {
|
_onGossip (data) {
|
||||||
if (!data) return
|
if (!data) return
|
||||||
this._stats.gossipIn++
|
this._stats.gossipIn++
|
||||||
|
|||||||
@@ -100,6 +100,15 @@ class HyperP2PDocumentLineLock extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { locks: this._locks.size }
|
||||||
|
}
|
||||||
|
|
||||||
|
acquireBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.acquire(e.docId, e.line))
|
||||||
|
}
|
||||||
|
|
||||||
_onGossip (data) {
|
_onGossip (data) {
|
||||||
if (!data) return
|
if (!data) return
|
||||||
this._stats.gossipIn++
|
this._stats.gossipIn++
|
||||||
|
|||||||
@@ -98,6 +98,15 @@ class HyperP2PWhiteboardOp extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { ops: this._log.length, rooms: this.listRooms() }
|
||||||
|
}
|
||||||
|
|
||||||
|
applyBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.apply(e.roomId, e.op))
|
||||||
|
}
|
||||||
|
|
||||||
_onGossip (data) {
|
_onGossip (data) {
|
||||||
if (data && data.type === 'wb-op' && data.entry) this.mergeRemote(data.entry)
|
if (data && data.type === 'wb-op' && data.entry) this.mergeRemote(data.entry)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,6 +133,10 @@ class HyperP2PAuctionGossip extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { auctions: this._auctions.size, open: this.listOpen().length }
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (payload) {
|
_gossip (payload) {
|
||||||
if (!this._peerMsgs) return
|
if (!this._peerMsgs) return
|
||||||
gossipSend(this, payload)
|
gossipSend(this, payload)
|
||||||
|
|||||||
@@ -102,6 +102,10 @@ class HyperP2PCreditLedger extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { accounts: this._accounts.size, totalSupply: this.totalSupply() }
|
||||||
|
}
|
||||||
|
|
||||||
_apply (accountId, delta, kind, reason) {
|
_apply (accountId, delta, kind, reason) {
|
||||||
assertNonEmpty(accountId, 'accountId')
|
assertNonEmpty(accountId, 'accountId')
|
||||||
const acct = this._accounts.get(accountId)
|
const acct = this._accounts.get(accountId)
|
||||||
|
|||||||
@@ -113,6 +113,10 @@ class HyperP2PMarketplaceListing extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { listings: this._listings.size, active: this.listActive().length }
|
||||||
|
}
|
||||||
|
|
||||||
removeAllActive () {
|
removeAllActive () {
|
||||||
const ids = this.listActive().map((l) => l.id)
|
const ids = this.listActive().map((l) => l.id)
|
||||||
for (const id of ids) this.removeListing(id)
|
for (const id of ids) this.removeListing(id)
|
||||||
|
|||||||
@@ -117,6 +117,14 @@ class HyperP2PAdaptiveStreamingEngine extends EventEmitter {
|
|||||||
return levels.map((levelMs) => this.reportBuffer(levelMs))
|
return levels.map((levelMs) => this.reportBuffer(levelMs))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return {
|
||||||
|
bufferMs: this.bufferMs(),
|
||||||
|
swarmHealth: this.swarmHealth(),
|
||||||
|
recommendation: { ...this._recommendation }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, { recommendation: this._recommendation })
|
return mediaStats(this._stats, PROTOCOL, { recommendation: this._recommendation })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,6 +122,15 @@ class HyperP2PBandwidthAggregator extends EventEmitter {
|
|||||||
return this.reset()
|
return this.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return {
|
||||||
|
streamId: this.streamId,
|
||||||
|
coverage: this.coverage(),
|
||||||
|
sources: this.sourceCount(),
|
||||||
|
maxSeq: this.maxSeq()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sourceCount () {
|
sourceCount () {
|
||||||
return this._sources.size
|
return this._sources.size
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,10 @@ class HyperP2PBufferHealthPredictor extends EventEmitter {
|
|||||||
return this.clearSamples()
|
return this.clearSamples()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { stallRisk: this.predictStallRisk(), samples: this.sampleCount() }
|
||||||
|
}
|
||||||
|
|
||||||
sampleCount () {
|
sampleCount () {
|
||||||
return this._samples.length
|
return this._samples.length
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,15 @@ class HyperP2PChunkSchedulerMedia extends EventEmitter {
|
|||||||
return this.clear()
|
return this.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { pending: this._queue.length, streamId: this.streamId }
|
||||||
|
}
|
||||||
|
|
||||||
|
enqueueBatch (chunks) {
|
||||||
|
if (!Array.isArray(chunks)) throw new Error('chunks array required')
|
||||||
|
return chunks.map((chunk) => this.enqueue(chunk))
|
||||||
|
}
|
||||||
|
|
||||||
cancelSeq (seq) {
|
cancelSeq (seq) {
|
||||||
const idx = this._queue.findIndex((e) => e.chunk.seq === seq)
|
const idx = this._queue.findIndex((e) => e.chunk.seq === seq)
|
||||||
if (idx < 0) return false
|
if (idx < 0) return false
|
||||||
|
|||||||
@@ -105,6 +105,10 @@ class HyperP2PContentProtection extends EventEmitter {
|
|||||||
return this.clearKeys()
|
return this.clearKeys()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { keys: this._keys.size, activeKeyId: this._activeKeyId }
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, { activeKeyId: this._activeKeyId, keys: this._keys.size })
|
return mediaStats(this._stats, PROTOCOL, { activeKeyId: this._activeKeyId, keys: this._keys.size })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,10 @@ class HyperP2PContributionLedger extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { contributors: this.contributorCount(), top: this.topContributors(5) }
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (payload) {
|
_gossip (payload) {
|
||||||
if (this._peerMsgs) {
|
if (this._peerMsgs) {
|
||||||
gossipSend(this, payload)
|
gossipSend(this, payload)
|
||||||
|
|||||||
@@ -114,6 +114,10 @@ class HyperP2PEnterpriseOrchestrator extends EventEmitter {
|
|||||||
return entries.map((e) => this.deployRegion(e.region, e.seedPeers || []))
|
return entries.map((e) => this.deployRegion(e.region, e.seedPeers || []))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { regions: [...this._regions.keys()], count: this._regions.size }
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, { regions: this._regions.size })
|
return mediaStats(this._stats, PROTOCOL, { regions: this._regions.size })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,6 +103,10 @@ class HyperP2PFecVideo extends EventEmitter {
|
|||||||
return this._groups.size
|
return this._groups.size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { groups: this.groupCount(), shards: this.totalShards() }
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, { groups: this._groups.size })
|
return mediaStats(this._stats, PROTOCOL, { groups: this._groups.size })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,10 @@ class HyperP2PHelperSwarmCoordinator extends EventEmitter {
|
|||||||
return { helpers: h, assignments: a }
|
return { helpers: h, assignments: a }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { helpers: this._helpers.size, assignments: this.assignmentCount() }
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (payload) {
|
_gossip (payload) {
|
||||||
if (this._peerMsgs) gossipSend(this, payload)
|
if (this._peerMsgs) gossipSend(this, payload)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,8 +87,12 @@ class HyperP2PLatencyOptimizer extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
pathCount () {
|
clearAll () {
|
||||||
return this._paths.size
|
return this.clearAllPaths()
|
||||||
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { paths: this.pathCount(), targetGlassMs: this.targetGlassMs, avgRtt: this.averageRtt() }
|
||||||
}
|
}
|
||||||
|
|
||||||
measureBatch (entries) {
|
measureBatch (entries) {
|
||||||
|
|||||||
@@ -92,6 +92,15 @@ class HyperP2PLiveEdgeManager extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { streams: this.streamIds(), count: this.streamCount() }
|
||||||
|
}
|
||||||
|
|
||||||
|
setLiveEdgeBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.setLiveEdge(e.streamId, e.seq, e.wallAt))
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, { streams: this._edges.size })
|
return mediaStats(this._stats, PROTOCOL, { streams: this._edges.size })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,6 +129,10 @@ class HyperP2PMediaChunker extends EventEmitter {
|
|||||||
return payloads.map((p) => this.segment(p.payload, { ...opts, ...p.opts }))
|
return payloads.map((p) => this.segment(p.payload, { ...opts, ...p.opts }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { stored: this._chunks.size, bytes: this._stats.bytes }
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, { stored: this._chunks.size })
|
return mediaStats(this._stats, PROTOCOL, { stored: this._chunks.size })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,6 +164,10 @@ class HyperP2PMediaTreeOrchestrator extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { nodes: this._nodes.size, root: this._root }
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (payload) {
|
_gossip (payload) {
|
||||||
if (!this._peerMsgs) return
|
if (!this._peerMsgs) return
|
||||||
gossipSend(this, payload)
|
gossipSend(this, payload)
|
||||||
|
|||||||
@@ -100,6 +100,15 @@ class HyperP2POriginHybridBridge extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { streams: this._origins.size, offloadRatio: this.p2pOffloadRatio() }
|
||||||
|
}
|
||||||
|
|
||||||
|
registerOriginBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.registerOrigin(e.streamId, e.url, e.weight))
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, {
|
return mediaStats(this._stats, PROTOCOL, {
|
||||||
offloadRatio: this.p2pOffloadRatio(),
|
offloadRatio: this.p2pOffloadRatio(),
|
||||||
|
|||||||
@@ -122,6 +122,15 @@ class HyperP2PPeerSelectorStreaming extends EventEmitter {
|
|||||||
.map(([region, count]) => ({ region, count }))
|
.map(([region, count]) => ({ region, count }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { peers: this.peerCount(), regions: this.topRegions(4) }
|
||||||
|
}
|
||||||
|
|
||||||
|
registerPeerBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.registerPeer(e.peerId, e.stats || {}))
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, { peers: this._peers.size })
|
return mediaStats(this._stats, PROTOCOL, { peers: this._peers.size })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,6 +102,10 @@ class HyperP2PQualityLadder extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { streams: this.listStreamIds(), ladders: this.ladderCount() }
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, { ladders: this._ladders.size })
|
return mediaStats(this._stats, PROTOCOL, { ladders: this._ladders.size })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,15 @@ class HyperP2PRetransmissionMedia extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { pending: this._nacks.size }
|
||||||
|
}
|
||||||
|
|
||||||
|
nackBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.nack(e.streamId, e.seq, e.reason))
|
||||||
|
}
|
||||||
|
|
||||||
resolveAll () {
|
resolveAll () {
|
||||||
const pending = this.pendingNacks()
|
const pending = this.pendingNacks()
|
||||||
for (const n of pending) this.resolve(n.streamId, n.seq)
|
for (const n of pending) this.resolve(n.streamId, n.seq)
|
||||||
|
|||||||
@@ -108,6 +108,15 @@ class HyperP2PStreamAccessControl extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { active: this.activeTokenCount(), total: this._tokens.size }
|
||||||
|
}
|
||||||
|
|
||||||
|
grantCapabilityBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.grantCapability(e.streamId, e.subject, e.ttlMs))
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, { active: this.listActive().length })
|
return mediaStats(this._stats, PROTOCOL, { active: this.listActive().length })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,15 @@ class HyperP2PStreamManifest extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { streams: this.listStreamIds(), count: this._manifests.size }
|
||||||
|
}
|
||||||
|
|
||||||
|
buildManifestBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.buildManifest(e.streamId, e.meta || {}))
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, { streams: this._manifests.size })
|
return mediaStats(this._stats, PROTOCOL, { streams: this._manifests.size })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,6 +124,10 @@ class HyperP2PStreamTelemetry extends EventEmitter {
|
|||||||
return entries.map((e) => this.recordQoE(e.sessionId, e.metrics || {}))
|
return entries.map((e) => this.recordQoE(e.sessionId, e.metrics || {}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clusterSnapshot () {
|
||||||
|
return this.aggregate()
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, { sessions: this._sessions.size })
|
return mediaStats(this._stats, PROTOCOL, { sessions: this._sessions.size })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -378,6 +378,10 @@ class HyperP2PDistributedEventBus extends EventEmitter {
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { topics: this.eventLog.size, peers: this.peerCount(), subscribers: this.subscriberCount() }
|
||||||
|
}
|
||||||
|
|
||||||
hasSeen (eventId) {
|
hasSeen (eventId) {
|
||||||
return this.seenEvents.has(String(eventId))
|
return this.seenEvents.has(String(eventId))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,6 +146,10 @@ class HyperP2PGossipMesh extends EventEmitter {
|
|||||||
return this.clearSeen()
|
return this.clearSeen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { seen: this._seen.size, peers: this.peerCount() }
|
||||||
|
}
|
||||||
|
|
||||||
hasSeen (id) {
|
hasSeen (id) {
|
||||||
return this._seen.has(String(id))
|
return this._seen.has(String(id))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,6 +141,10 @@ class HyperP2PSubscriptionLease extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { leases: this._leases.size, channels: this.listChannels() }
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return { ...this._stats, active: this._leases.size, protocol: PROTOCOL }
|
return { ...this._stats, active: this._leases.size, protocol: PROTOCOL }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,10 @@ class HyperP2PTopicChannel extends EventEmitter {
|
|||||||
return [...this._retained.keys()]
|
return [...this._retained.keys()]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { channels: this._subs.size, retained: this._retained.size }
|
||||||
|
}
|
||||||
|
|
||||||
_deliverLocal (channel, payload, meta) {
|
_deliverLocal (channel, payload, meta) {
|
||||||
const handler = this._subs.get(channel)
|
const handler = this._subs.get(channel)
|
||||||
if (handler) {
|
if (handler) {
|
||||||
|
|||||||
@@ -92,6 +92,10 @@ class HyperP2PStreamBackpressure extends EventEmitter {
|
|||||||
return this.clear()
|
return this.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { bytes: this._bytes, paused: this._paused, highWater: this.highWaterMark }
|
||||||
|
}
|
||||||
|
|
||||||
writeBatch (chunks) {
|
writeBatch (chunks) {
|
||||||
if (!Array.isArray(chunks)) throw new Error('chunks array required')
|
if (!Array.isArray(chunks)) throw new Error('chunks array required')
|
||||||
return chunks.map((chunk) => this.write(chunk))
|
return chunks.map((chunk) => this.write(chunk))
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ class HyperP2PStreamChunker extends EventEmitter {
|
|||||||
return this.reset()
|
return this.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { pending: this._pending.length, chunkSize: this.chunkSize }
|
||||||
|
}
|
||||||
|
|
||||||
flush () {
|
flush () {
|
||||||
if (!this._pending.length) return null
|
if (!this._pending.length) return null
|
||||||
const tail = this._pending
|
const tail = this._pending
|
||||||
|
|||||||
@@ -123,6 +123,10 @@ class HyperP2PStreamMultiplex extends EventEmitter {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { open: this._streams.size, frames: this._stats.frames, bytes: this._stats.bytes }
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return {
|
return {
|
||||||
...this._stats,
|
...this._stats,
|
||||||
|
|||||||
@@ -116,6 +116,10 @@ class HyperP2PStreamResumeToken extends EventEmitter {
|
|||||||
return this.reset()
|
return this.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { offset: this._offset, tokens: this._tokens.size }
|
||||||
|
}
|
||||||
|
|
||||||
writeBatch (chunks) {
|
writeBatch (chunks) {
|
||||||
if (!Array.isArray(chunks)) throw new Error('chunks array required')
|
if (!Array.isArray(chunks)) throw new Error('chunks array required')
|
||||||
return chunks.map((c) => this.write(c))
|
return chunks.map((c) => this.write(c))
|
||||||
|
|||||||
@@ -91,6 +91,10 @@ class HyperP2PStreamTee extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { branches: this._branches.size }
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return { ...this._stats, branchCount: this._branches.size, protocol: PROTOCOL }
|
return { ...this._stats, branchCount: this._branches.size, protocol: PROTOCOL }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,10 @@ class HyperP2PStreamTransform extends EventEmitter {
|
|||||||
return this.clearPending()
|
return this.clearPending()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { pending: this._out.length }
|
||||||
|
}
|
||||||
|
|
||||||
writeBatch (chunks) {
|
writeBatch (chunks) {
|
||||||
if (!Array.isArray(chunks)) throw new Error('chunks must be an array')
|
if (!Array.isArray(chunks)) throw new Error('chunks must be an array')
|
||||||
let ok = 0
|
let ok = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user