Expand description
Live updates for connected dashboard clients.
The dashboard normally runs as its own process (the hammerwork-web binary), apart
from the workers. Job lifecycle events published to a worker’s in-process
EventManager never reach it, so the dashboard
learns about changes from the database they all share: LiveUpdates polls it on an
interval and pushes what changed to the WebSocket clients, honouring each client’s
subscriptions:
- a
JobUpdatemessage (event typejob_updates) for each job that was created, started, completed, failed or timed out since the previous poll; - a
QueueUpdatemessage (event typequeue_updates) for each queue whose statistics changed.
The work is bounded: nothing is queried while no client is connected, one poll reads
at most WebSocketConfig::live_update_max_jobs
changed jobs, and the memory of what was already sent only covers a short window.
An application that embeds the dashboard in the same process as its workers can also
forward their events directly with forward_job_events, which delivers them without
waiting for the next poll.
Structs§
- Live
Updates - Polls the database for job and queue changes and pushes them to WebSocket clients.
- Poll
Outcome - What one poll pushed.
Constants§
- POLL_
OVERLAP - How far back each poll looks before the previous one, so a change whose transaction committed after that poll ran (with a timestamp from before it) is still seen.
Functions§
- forward_
job_ events - Forward the job lifecycle events of an in-process
EventManagersubscription to the WebSocket clients subscribed tojob_updates, until the event manager is dropped. - job_
update_ from_ event - The
JobUpdatesent for a job lifecycle event.