Runnable Example Applications¶
The repository ships 10 runnable realtime dashboard applications under examples/htmx_realtime_{websocket,sse}*/ (sharing common queue and UI logic in examples/htmx_realtime_common.py) that demonstrate litestar-queues paired with Litestar Channels, HTMX, Server-Sent Events (SSE), and WebSockets across every storage backend and both in-process and external worker topologies.
Realtime HTMX Dashboard (examples/htmx_realtime_*)¶
The realtime dashboard applications demonstrate:
- In-Task Progress & Structured Logs: Tasks inject
TaskExecutionContext(ctx.progress(),ctx.log(),ctx.event()) to stream multi-stage progress bars and live log lines to connected browsers. - Dual Transport Support: Switch between WebSockets (
WS /queues/events) and Server-Sent Events (GET /queues/events/sse) with automaticLast-Event-ID/after_sequencecursor replay fromQueueEventLog. - Pluggable Storage & Worker Topologies: Run the exact same application logic against
memory,sqlspec(SQLite/PostgreSQL),advanced_alchemy,redis, orvalkeyin either single-process (placement="asgi") or external worker (placement="external") mode.
Example Application Matrix¶
| Entrypoint Module | Storage Backend | Realtime Stream Transport | Default Worker Topology |
|---|---|---|---|
examples.htmx_realtime_websocket.app:app |
InMemoryQueueBackend |
WebSocket (/queues/events) |
In-process (placement="asgi") |
examples.htmx_realtime_sse.app:app |
InMemoryQueueBackend |
Server-Sent Events (/queues/events/sse) |
In-process (placement="asgi") |
examples.htmx_realtime_websocket_sqlspec.app:app |
SQLSpecQueueBackend (SQLite / Postgres) |
WebSocket (/queues/events) |
Configurable (asgi, server, external) |
examples.htmx_realtime_sse_sqlspec.app:app |
SQLSpecQueueBackend (SQLite / Postgres) |
Server-Sent Events (/queues/events/sse) |
Configurable (asgi, server, external) |
examples.htmx_realtime_websocket_advanced_alchemy.app:app |
SQLAlchemyBackend (Advanced Alchemy) |
WebSocket (/queues/events) |
Configurable (asgi, server, external) |
examples.htmx_realtime_sse_advanced_alchemy.app:app |
SQLAlchemyBackend (Advanced Alchemy) |
Server-Sent Events (/queues/events/sse) |
Configurable (asgi, server, external) |
examples.htmx_realtime_websocket_redis.app:app |
RedisQueueBackend (redis>=8.1.0) |
WebSocket (/queues/events) |
Configurable (asgi, server, external) |
examples.htmx_realtime_sse_redis.app:app |
RedisQueueBackend (redis>=8.1.0) |
Server-Sent Events (/queues/events/sse) |
Configurable (asgi, server, external) |
examples.htmx_realtime_websocket_valkey.app:app |
ValkeyQueueBackend (valkey>=6.0.0) |
WebSocket (/queues/events) |
Configurable (asgi, server, external) |
examples.htmx_realtime_sse_valkey.app:app |
ValkeyQueueBackend (valkey>=6.0.0) |
Server-Sent Events (/queues/events/sse) |
Configurable (asgi, server, external) |
Running the Examples Locally¶
Zero-Dependency Memory or SQLSpec SQLite¶
Run the in-memory or SQLSpec SQLite dashboard directly with uv:
Open http://127.0.0.1:8000 in your browser to enqueue tasks, watch live stage progress bars, inspect durable QueueEventLog history, and test cancellation or simulated failures.
Two-Process External Worker Topology¶
To test cross-process queue execution and durable QueueEventLog replay between separate web and worker processes: