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 Connected 86834 events logged
Services
๐Ÿ“ฆ
Orders ๐Ÿ”’
bufferingโ€ฆ
19298 events
๐Ÿ’ณ
Payments ๐Ÿ”’
payment.refunded
29375 events
๐Ÿ”
Auth ๐Ÿ“ก
login.failure
19145 events
๐Ÿ“Š
Inventory ๐Ÿ“ก
stock.restocked
19016 events
NATS
Core via.events.* auth, inventory
JetStream VIAEVENTS 86834 msgs
Durable ui-orders, ui-payments ACK guaranteed
KV viahealth heartbeats
Audit via.events.* 97359 โœ“
Health (KV age)
๐Ÿ“ฆ Orders 0.5s
๐Ÿ“ฆ DOWN
๐Ÿ’ณ Payments 0.5s
๐Ÿ’ณ DOWN
๐Ÿ” Auth 34324.5s
๐Ÿ” DOWN
๐Ÿ“Š Inventory 34322.5s
๐Ÿ“Š DOWN
Event Stream
๐Ÿ’ณ payment.refunded $331 USD 03:01:11.978
๐Ÿ’ณ payment.failed $350 USD 03:01:07.884
๐Ÿ’ณ payment.authorized $453 USD 03:01:03.334
๐Ÿ’ณ payment.failed $176 USD 03:01:01.455
๐Ÿ’ณ payment.authorized $75 USD 03:00:56.752
๐Ÿ’ณ payment.authorized $449 USD 03:00:53.005
๐Ÿ’ณ payment.failed $378 USD 03:00:47.445
๐Ÿ’ณ payment.refunded $372 USD 03:00:44.885
๐Ÿ’ณ payment.failed $262 USD 03:00:42.863
๐Ÿ’ณ payment.authorized $35 USD 03:00:38.600
๐Ÿ’ณ payment.refunded $141 USD 03:00:37.757
๐Ÿ’ณ payment.authorized $487 USD 03:00:36.795
๐Ÿ’ณ payment.failed $74 USD 03:00:31.522
๐Ÿ’ณ payment.failed $361 USD 03:00:28.025
๐Ÿ’ณ payment.authorized $269 USD 03:00:19.941
๐Ÿ’ณ payment.authorized $192 USD 03:00:11.618
๐Ÿ’ณ payment.refunded $428 USD 03:00:04.505
๐Ÿ’ณ payment.failed $484 USD 03:00:00.838
๐Ÿ’ณ payment.failed $169 USD 02:59:59.530
๐Ÿ’ณ payment.authorized $444 USD 02:59:57.677
๐Ÿ’ณ payment.authorized $247 USD 02:59:53.477
๐Ÿ’ณ payment.authorized $153 USD 02:59:52.498
๐Ÿ’ณ payment.failed $233 USD 02:59:51.378
๐Ÿ’ณ payment.refunded $158 USD 02:59:44.736
๐Ÿ’ณ payment.failed $36 USD 02:59:43.060
๐Ÿ’ณ payment.refunded $157 USD 02:59:41.845
๐Ÿ’ณ payment.refunded $181 USD 02:59:38.736
๐Ÿ’ณ payment.failed $364 USD 02:59:30.984
๐Ÿ’ณ payment.failed $456 USD 02:59:30.098
๐Ÿ’ณ payment.authorized $126 USD 02:59:28.192

๐ŸŽฏ 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.