44 lines
1.3 KiB
Markdown
44 lines
1.3 KiB
Markdown
# hyper-p2p-bucket-rate-limit
|
|
|
|
Production measurement & rate control module: Hyperswarm discovery + Protomux when `topic` is set.
|
|
|
|
**Category:** Measurement & rate control
|
|
|
|
**Composes with:** `hyper-p2p-congestion-signal`, `hyper-p2p-bandwidth-broker`
|
|
|
|
**Protocol:** `bucket-rate-limit/v1`
|
|
|
|
## When to use
|
|
|
|
Multi-peer apps that need measurement & rate control over a shared Hyperswarm topic.
|
|
|
|
## When not to use
|
|
|
|
Single-process tools with no P2P topic (use local APIs only or skip `ready()`).
|
|
|
|
## Quick start
|
|
|
|
```js
|
|
const { HyperP2PBucketRateLimit } = require('hyper-p2p-bucket-rate-limit')
|
|
const topic = process.argv[2] // 64-char hex or string
|
|
const mod = new HyperP2PBucketRateLimit({ topic, enableBackgroundTimers: false })
|
|
await mod.ready() // joins swarm when topic set
|
|
// ... application logic ...
|
|
await mod.close()
|
|
```
|
|
|
|
## Docs
|
|
|
|
- [docs/api.md](docs/api.md) — constructor, methods, events, errors
|
|
- [docs/architecture.md](docs/architecture.md) — wire types, state, composition
|
|
- [../_shared/PRODUCTION.md](../../_shared/PRODUCTION.md) — production checklist
|
|
- [../_shared/DOC_STANDARDS.md](../../_shared/DOC_STANDARDS.md) — documentation standards
|
|
|
|
- Integration: [`../../real_tests/integration/`](../../../real_tests/integration/) — `bucket-rate-limit-two-node.js`
|
|
|
|
## Test
|
|
|
|
```bash
|
|
npm install && npm test
|
|
```
|