Add call protocol module with streaming support
New sub-path export @alkdev/pubsub/call providing:
- CallEventSchema (TypeBox schemas) for call.requested/responded/part/completed/aborted/error
- PendingRequestMap with call() (request/response) and subscribe() (streaming via Repeater)
- CallError class and CallErrorCode constants
- Scoped topic subscriptions (call.responded:{requestId}) to avoid O(n) fanout
- subscribe() yields call.part events until call.completed or call.error,
with automatic call.aborted on consumer break
Also adds @alkdev/typebox as runtime dependency and architecture doc.
This commit is contained in:
@@ -30,7 +30,8 @@ const pubsub = createPubSub<MyEventMap>({
|
||||
|
||||
## What This Package Provides
|
||||
|
||||
- **Core** — `createPubSub`, `TypedEventTarget`, `TypedEvent`, topic scoping, `filter`/`map`/`pipe` operators
|
||||
- **Core** — `createPubSub`, `TypedEventTarget`, `TypedEvent`, topic scoping, `filter`/`map`/`pipe` operators, `Repeater` (inlined from @repeaterjs/repeater)
|
||||
- **Call protocol** (`@alkdev/pubsub/call`) — `PendingRequestMap`, `CallEventSchema`, `CallError`, event types for request/response and streaming operations
|
||||
- **Adapters** (each is a peer-dep island, importable via sub-path export):
|
||||
- In-process (default `EventTarget`, no adapter needed)
|
||||
- Redis (`@alkdev/pubsub/event-target-redis`, peer dep: `ioredis`)
|
||||
@@ -51,7 +52,7 @@ The hub uses pubsub for event routing between operations, runners, and the SSE i
|
||||
|
||||
### Future: standalone spoke SDK
|
||||
|
||||
Spokes will import `@alkdev/pubsub` directly to create their event target (WebSocket or Iroh) and wire it into `createPubSub`. The call protocol types live in a separate `@alkdev/call-protocol` package (not yet extracted).
|
||||
Spokes will import `@alkdev/pubsub` directly to create their event target (WebSocket or Iroh) and wire it into `createPubSub`. Call protocol types and `PendingRequestMap` are available from `@alkdev/pubsub/call`.
|
||||
|
||||
## Threat Model
|
||||
|
||||
@@ -64,6 +65,7 @@ Spokes will import `@alkdev/pubsub` directly to create their event target (WebSo
|
||||
| Document | Content |
|
||||
|----------|---------|
|
||||
| [api-surface.md](api-surface.md) | createPubSub factory, PubSub types, operators, TypedEventTarget types |
|
||||
| [call-protocol.md](call-protocol.md) | Call/subscribe protocol — event types, PendingRequestMap, streaming, error model, transport mapping |
|
||||
| [event-targets.md](event-targets.md) | In-process, Redis, WebSocket adapters — interface, configuration, limitations |
|
||||
| [iroh-transport.md](iroh-transport.md) | Iroh P2P QUIC transport — protocol, framing, identity, hub/spoke sides, reconnection |
|
||||
| [build-distribution.md](build-distribution.md) | Dependencies, project structure, tree-shaking, sub-path exports, targets |
|
||||
|
||||
Reference in New Issue
Block a user