Updates
This commit is contained in:
@@ -1,23 +1,84 @@
|
||||
# hyper-p2p-stats-exporter API
|
||||
# API: hyper-p2p-stats-exporter
|
||||
|
||||
**Status:** scaffold · **Protocol:** `stats-exporter/v1`
|
||||
**Protocol:** `stats-exporter/v1`
|
||||
|
||||
## Class `HyperP2PStatsExporter`
|
||||
**Export:** `HyperP2PStatsExporter`
|
||||
|
||||
Scaffold stub — methods throw `not implemented: scaffold` until promoted to production tier.
|
||||
## Overview
|
||||
|
||||
### `constructor(opts?)`
|
||||
Production p2p module: Hyperswarm discovery + Protomux when `topic` is set.
|
||||
|
||||
### `getStats()`
|
||||
## Constructor
|
||||
|
||||
Returns `{ created, errors, protocol, tier: 'scaffold' }`.
|
||||
```js
|
||||
const mod = new HyperP2PStatsExporter(opts)
|
||||
```
|
||||
|
||||
### `ready()`
|
||||
| Option | Type | Default | Description |
|
||||
|--------|------|---------|-------------|
|
||||
| `topic` | `string` | `Buffer` | `null` | Hyperswarm topic; required for P2P `ready()` |
|
||||
| `keyPair` | KeyPair | random | Ed25519 key pair |
|
||||
|
||||
Resolves immediately (no-op).
|
||||
## Methods
|
||||
|
||||
## Wire (planned)
|
||||
### `register(name, getStatsFn)`
|
||||
|
||||
| Message | Direction | Notes |
|
||||
|---------|-----------|-------|
|
||||
| TBD | gossip | Defined in implementation pass |
|
||||
- **Returns:** `value`
|
||||
- **Throws:**
|
||||
- `Error: getStatsFn required`
|
||||
- `Error: name required`
|
||||
|
||||
### `unregister(name)`
|
||||
|
||||
- **Returns:** `value`
|
||||
- **Throws:** — (none documented in method body)
|
||||
|
||||
### `snapshot(—)`
|
||||
|
||||
- **Returns:** `value`
|
||||
- **Throws:** — (none documented in method body)
|
||||
|
||||
### `toJSON(—)`
|
||||
|
||||
- **Returns:** `value`
|
||||
- **Throws:** — (none documented in method body)
|
||||
|
||||
### `getStats(—)`
|
||||
|
||||
- **Returns:** `object`
|
||||
- **Throws:** — (none documented in method body)
|
||||
|
||||
### `ready(—)`
|
||||
|
||||
- **Returns:** `Promise`
|
||||
- **Throws:** — (none documented in method body)
|
||||
|
||||
### `close(—)`
|
||||
|
||||
- **Returns:** `Promise<void>`
|
||||
- **Throws:** — (none documented in method body)
|
||||
|
||||
## Events
|
||||
|
||||
| Event | Payload |
|
||||
|-------|---------|
|
||||
| `snapshot` | out |
|
||||
|
||||
## getStats()
|
||||
|
||||
Returns `{ ...this._stats }` — typically `ops`, `errors`, and module-specific counters (`created`, `relays`, `open`, `peers`, etc.).
|
||||
Library-only modules may include `mode: 'local'`.
|
||||
|
||||
## Errors
|
||||
|
||||
Stable message substrings: see [`../../_shared/ERROR_CODES.md`](../../_shared/ERROR_CODES.md).
|
||||
|
||||
## P2P
|
||||
|
||||
When `topic` is set, `ready()` joins Hyperswarm and opens Protomux `stats-exporter/v1`.
|
||||
|
||||
## Testing
|
||||
|
||||
```bash
|
||||
npm install && npm test
|
||||
```
|
||||
|
||||
@@ -1,15 +1,27 @@
|
||||
# hyper-p2p-stats-exporter architecture
|
||||
# Architecture: hyper-p2p-stats-exporter
|
||||
|
||||
**Tier:** scaffold · **Category:** `observability`
|
||||
**Category:** General
|
||||
|
||||
## Role
|
||||
```mermaid
|
||||
flowchart LR
|
||||
App[Application] --> Mod[HyperP2PStatsExporter]
|
||||
Mod --> Mux[Protomux stats-exporter/v1]
|
||||
Mux --> Swarm[Hyperswarm]
|
||||
```
|
||||
|
||||
Stats export format.
|
||||
## Wire messages
|
||||
|
||||
| type | fields | direction | behavior |
|
||||
|------|--------|-----------|----------|
|
||||
| *(local only)* | — | — | No gossip wire types |
|
||||
|
||||
## State model
|
||||
|
||||
- In-memory `Map` / `Set` structures for hot path
|
||||
- Optional Hyperbee/Hypercore persistence when `storageDir` or `memoryOnly` is configured
|
||||
- `close()` tears down swarm, timers, and clears ephemeral state
|
||||
|
||||
## Composition
|
||||
|
||||
Uses `../../_shared/p2p-bare.js` for Hyperswarm + Protomux when implemented. Does **not** duplicate Holepunch core storage/transport.
|
||||
Composes with: see MODULE_CATEGORIES.md.
|
||||
|
||||
## Holepunch boundary
|
||||
|
||||
Inspiration: n/a
|
||||
|
||||
Reference in New Issue
Block a user