subscriber
subscriber
¶
Render clearance-hub events as desktop notifications.
Turns the event stream from ClearanceClient into calls on an
injected Notifier: a block arrives, the operator sees a popup
with Allow/Deny actions, clicks route back to the hub as a Verdict.
Live-block dedup, shield-down popup tracking, and task-identity
resolution live here because they're all presentation concerns —
the hub stays transport-only.
EventSubscriber(notifier, client=None, *, identity_resolver=None, socket_path=None)
¶
Bridge clearance-hub events into desktop notifications.
Owns the presentation-layer state a rendering client needs: live-block
dedup keyed on (container, target), the tracked ShieldDown
popup per container so ShieldUp can retire it, and verdict routing
through notifier action callbacks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notifier
|
Notifier
|
Desktop notification backend (any |
required |
client
|
ClearanceClient | None
|
Pre-configured |
None
|
identity_resolver
|
Callable[[str], ContainerIdentity] | None
|
Turns a short container ID into a
|
None
|
socket_path
|
Path | None
|
Clearance-socket override when client isn't supplied (tests). |
None
|
Initialise the subscriber with a notifier and transport.
Source code in src/terok_clearance/client/subscriber.py
start()
async
¶
Connect to the clearance hub and begin rendering its event stream.
stop()
async
¶
Drain pending tasks and close the transport.
Closes the client first so no new handler tasks are scheduled,
then awaits the currently-tracked tasks to settle (with their
own CancelledError suppressed). A bare sleep(0) would
yield only one loop turn — not enough for cancellation to
propagate through chained awaits — and tasks.clear() on its
own would drop references to tasks still writing to handles we
then close.