Examples menu

๐Ÿ›ฐ NATS Visualizer

Four simulated microservices publish events over NATS. Watch Core pub/sub, JetStream persistence, and KV health heartbeats update in real time.

OpenSwoole-native NATS client โ€” a thin coroutine-native TCP client replaces third-party NATS libraries that require incompatible event loops. The read loop runs in a dedicated coroutine and yields cooperatively on every recv().
Core pub/sub (best-effort) โ€” Auth and Inventory subscribe via wildcard Core pub/sub (via.events.*). Fire-and-forget: if you kill one of these services its simulator stops and any events published while it is offline are gone forever.
Guaranteed delivery (JetStream durable consumers) โ€” Orders and Payments subscribe via named durable push consumers with explicit ACK. Kill = pause the consumer: the simulator keeps publishing, JetStream buffers un-ACKed messages. Revive = re-subscribe: the burst of missed events arrives immediately.
JetStream persistence โ€” the VIAEVENTS stream captures every message in memory. The durable consumer tracks its last-delivered sequence across subscribe/unsubscribe cycles โ€” a revived subscriber never misses a message.
KV health heartbeats โ€” each service publishes a heartbeat to $KV.viahealth.{service} every 2 s. Guaranteed services always heartbeat (only the consumer is paused); best-effort services stop heartbeating when killed. The health grid reads KV age.
Lazy init โ€” the NATS connection is established on the first page load inside the HTTP coroutine, where coroutine APIs are always safe. A double-init guard (flag set before Coroutine::create()) prevents race conditions.
NATS Connectingโ€ฆ 0 events logged
Services
๐Ÿ“ฆ
Orders ๐Ÿ”’
โ€” waiting โ€”
0 events
๐Ÿ’ณ
Payments ๐Ÿ”’
โ€” waiting โ€”
0 events
๐Ÿ”
Auth ๐Ÿ“ก
โ€” waiting โ€”
0 events
๐Ÿ“Š
Inventory ๐Ÿ“ก
โ€” waiting โ€”
0 events
NATS
Core via.events.* auth, inventory
JetStream VIAEVENTS 0 msgs
Durable ui-orders, ui-payments ACK guaranteed
KV viahealth heartbeats
Audit via.events.* 0 โœ“
Health (KV age)
๐Ÿ“ฆ Orders โ€”
๐Ÿ“ฆ DOWN
๐Ÿ’ณ Payments โ€”
๐Ÿ’ณ DOWN
๐Ÿ” Auth โ€”
๐Ÿ” DOWN
๐Ÿ“Š Inventory โ€”
๐Ÿ“Š DOWN
Event Stream
Waiting for eventsโ€ฆ

๐ŸŽฏ Actions

kill-orders / kill-payments

Pauses the JetStream durable consumer (unsubscribes from the deliver inbox). Simulator keeps publishing; NATS buffers un-ACKed messages. Health tile stays green โ€” the service is still alive, only the consumer is paused.

kill-auth / kill-inventory

Stops the event simulator entirely. Events are silently dropped โ€” Core pub/sub has no persistence. Health tile flips to DOWN after 8 s of silence.

revive-{service} (ร—4)

Guaranteed services: re-subscribes to the deliver inbox; JetStream immediately delivers all buffered events in a burst. Best-effort: restarts the simulator and publishes a fresh KV heartbeat.

๐Ÿ‘ Views

mission_control.html.twig

Flow diagram piping services โ†’ NATS โ†’ browser, service kill/revive cards with delivery-type badges, NATS topology with health tiles, and a live event stream.