Recipes

The core relayhub object is a lightweight wrapper that manages the lifecycle of your event stream.

Batching is automatic—control it via `batch(100)` or `batch({ size: 50, timeoutMs: 1000 })` to trade latency for throughput.

stream.pipe(map(e => e.data), buffer(100, 5000), flatMap(batch => fetch('/api/bulk',  body: JSON.stringify(batch) ))).catch(console.error);

Graceful shutdown waits for in-flight events to complete, then closes connections cleanly—no lost events, no crashes.

Recipes

Metrics are published to standard formats (Prometheus, CloudWatch, DataDog) with zero configuration.

await stream.on('user.created', async (event) =>  console.log(event.data.email); );

Batching is automatic—control it via `batch(100)` or `batch({ size: 50, timeoutMs: 1000 })` to trade latency for throughput.

See also