Expand pubsub, economy, routing-advanced, and platform categories.
Manual pass adds listChannels, totalSupply, openCount, listSessionIds, new api.md files, corrected trust/reactive/conflict getStats docs, and category README hubs for routing-advanced, measurement, pear-platform, and trust-security. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -1,85 +1,25 @@
|
||||
# API: hyper-p2p-qos-topic
|
||||
|
||||
**Protocol:** `qos-topic/v1`
|
||||
**Protocol:** `qos-topic/v1` · **Export:** `HyperP2PQosTopic`
|
||||
|
||||
**Export:** `HyperP2PQosTopic`, `PROTOCOL`
|
||||
|
||||
## Overview
|
||||
|
||||
Priority pub/sub with three QoS queues (0–2). Higher QoS messages drain before lower; subscribers declare minimum QoS per channel. Publishes gossip as `qos-publish`.
|
||||
|
||||
## Constructor
|
||||
|
||||
| Option | Description |
|
||||
|--------|-------------|
|
||||
| `topic` | Hyperswarm topic |
|
||||
| `keyPair` | Publisher identity |
|
||||
QoS tiers `0` (low) … `2` (high). Drain processes higher tiers first.
|
||||
|
||||
## Methods
|
||||
|
||||
### `subscribe(channel, handler, qos?)`
|
||||
### `subscribe(channel, handler, qos?) → unsubscribe`
|
||||
|
||||
Default subscriber QoS `0`. Handler receives messages where `msg.qos >= sub.qos`.
|
||||
Handler receives messages where `msg.qos >= sub.qos`.
|
||||
|
||||
### `publish(channel, payload, opts?)`
|
||||
### `publish(channel, payload, opts?) → msg`
|
||||
|
||||
- **opts.qos** — clamped 0–2
|
||||
- Enqueues then `_drain()` priority order
|
||||
### `pending(qos?) → number` — queue depth
|
||||
|
||||
### `pending(qos?)`
|
||||
### `listChannels()` / `hasHandler(channel)`
|
||||
|
||||
Queue depth for one level or total.
|
||||
### `getStats() → { published, delivered, pending, protocol }`
|
||||
|
||||
### `getStats()` / `ready()` / `close()`
|
||||
|
||||
`published`, `delivered`, `gossipIn`, `gossipOut`.
|
||||
### `async ready()` / `async close()`
|
||||
|
||||
## Wire
|
||||
|
||||
| type | fields |
|
||||
|------|--------|
|
||||
| `qos-publish` | `channel`, `payload`, `qos`, `from`, `at` |
|
||||
|
||||
## Events
|
||||
|
||||
`message`.
|
||||
|
||||
## Errors
|
||||
|
||||
`assertNonEmpty(channel)`, invalid handler.
|
||||
|
||||
## Composition
|
||||
|
||||
`hyper-p2p-topic-channel` for retain; Messaging stack `qos-topic-two-node.js`.
|
||||
|
||||
## Testing
|
||||
|
||||
`npm test`, integration smoke.
|
||||
|
||||
## Example
|
||||
|
||||
`examples/basic.js`
|
||||
|
||||
## State model
|
||||
|
||||
Three queues `_queues[0..2]`; drain processes highest index first.
|
||||
|
||||
## Performance
|
||||
|
||||
`pending()` walks all queues; bound publish rate if memory grows.
|
||||
|
||||
## Versioning
|
||||
|
||||
`qos-topic/v1` publish type unchanged since flagship release.
|
||||
|
||||
## Security
|
||||
|
||||
No encryption; use `hyper-p2p-encrypted-topic` for sensitive channels.
|
||||
|
||||
## Related modules
|
||||
|
||||
- `hyper-p2p-topic-channel` — retain and subscribe
|
||||
|
||||
## See also
|
||||
|
||||
[`docs/architecture.md`](architecture.md)
|
||||
`qos-publish` — enqueued by remote peer then drained locally.
|
||||
|
||||
Reference in New Issue
Block a user