Expand description
Generic streaming infrastructure for authenticated PUB/SUB communication.
This module provides rate-controlled, MAC-authenticated streaming that works for both inference (UTF-8 tokens) and worker I/O (arbitrary binary data).
§Architecture
Producer Consumer
──────── ────────
StreamChannel::publisher() MoqStreamHandle::new()
│ │
│ publish_data() │ recv_next()
▼ ▼
moq UDS track ──────────► StreamVerifier§Wire Format
Moq track payload (binary): capnp StreamBlock + 16-byte truncated HMAC appended
§Security
- DH key exchange: Ristretto255 ECDH derives topic + mac_key
- MAC chain: Each block’s MAC depends on previous, enforces ordering
§Backend
- Default: Blake3
keyed_hash()(~10+ GB/s with SIMD) - FIPS mode: HMAC-SHA256 (FIPS 198-1)
Re-exports§
pub use crate::stream_info::StreamInfo;pub use crate::stream_consumer::StreamPayload;pub use crate::stream_consumer::StreamVerifier;
Structs§
- Batching
Config - Configuration for adaptive batching (rate control).
- Channel
Progress Reporter - Channel-based progress sender for use with git2db or other progress-reporting operations.
- Response
Stream - Wrapper type for streaming responses that coordinates the REP-before-PUB pattern.
- Stream
Channel - Service-level async streaming infrastructure that encapsulates socket management and stream pre-authorization.
- Stream
Context - Encapsulates all state needed to produce a stream.
- Stream
Guard - Codegen hook point for dispatch-level streaming continuation wrapping.
- Stream
Hmac State - HMAC chain state for StreamBlock with 16-byte truncated MACs.
Enums§
- Progress
Update - Progress update message for channel-based streaming.
- Stream
Payload Data - Input payload for StreamBuilder (what gets serialized).
Constants§
- DEFAULT_
MAX_ CONCURRENT_ STREAMS_ PER_ SERVICE - Default ceiling on concurrent server-side streaming responses per
service — i.e. how many streaming RPCs one service may be actively pushing
data for at once. Overridable via
install_max_concurrent_streams_per_service(wired fromServerConfig::max_concurrent_streams_per_service).
Functions§
- derive_
client_ stream_ keys - Derive the
(mac_key, enc_key, topic)triple from a client-side DH exchange (#321). - encode_
stream_ block - Encode a
StreamBlockcapnp message from aprev_mac+ payload list. - encode_
stream_ block_ with_ provenance - Encode a
StreamBlockwith an optional per-host provenance signature (#321). - install_
max_ concurrent_ streams_ per_ service - Install the per-service concurrent-streams cap. Call once at startup with
ServerConfig::max_concurrent_streams_per_service. Values are clamped to a minimum of 1. ReturnsErr(existing)if already installed (first-write-wins). - progress_
channel - Create a progress channel for streaming operations.
- spawn_
streaming_ response - Spawn the server-side half of a streaming RPC — the task that keeps pushing
data after the
StreamInforeply has been sent — onto the currentLocalSet, bounded by a per-service admission permit.