callback
callback
¶
Callback-driven notifier for programmatic consumers.
CallbackNotifier is a headless Notifier backend that invokes
user-supplied callables instead of rendering UI. It enables any
consumer — Textual TUI, web dashboard, CLI tool — to build its own
presentation on top of the EventSubscriber signal pipeline without
depending on a D-Bus desktop notification daemon.
Typical usage::
notifier = CallbackNotifier(on_notify=my_handler)
subscriber = EventSubscriber(notifier)
await subscriber.start()
Notification(nid, summary, body, actions, replaces_id, timeout_ms, container_id='', container_name='', project='', task_id='', task_name='')
dataclass
¶
Snapshot of a single notification posted by the subscriber.
The identity fields (container_id, container_name,
project, task_id, task_name) are presentation-layer
context the subscriber's identity_resolver produced — empty
strings when unresolved. The desktop DbusNotifier
discards all of them; the TUI uses the task triple to render a
Task column for terok-managed containers and falls back to the
container name for standalone ones.
nid
instance-attribute
¶
summary
instance-attribute
¶
body
instance-attribute
¶
actions
instance-attribute
¶
replaces_id
instance-attribute
¶
timeout_ms
instance-attribute
¶
container_id = ''
class-attribute
instance-attribute
¶
container_name = ''
class-attribute
instance-attribute
¶
project = ''
class-attribute
instance-attribute
¶
task_id = ''
class-attribute
instance-attribute
¶
task_name = ''
class-attribute
instance-attribute
¶
CallbackNotifier(on_notify=None, *, on_container_started=None, on_container_exited=None, on_shield_up=None, on_shield_down=None, on_shield_down_all=None)
¶
Notifier backend that delegates rendering to caller-supplied hooks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
on_notify
|
Callable[[Notification], None] | None
|
Called for every |
None
|
on_container_started
|
Callable[[str], None] | None
|
Called for every |
None
|
on_container_exited
|
Callable[[str, str], None] | None
|
Called for every |
None
|
on_shield_up
|
Callable[[str], None] | None
|
Called for every |
None
|
on_shield_down
|
Callable[[str], None] | None
|
Called for every |
None
|
on_shield_down_all
|
Callable[[str], None] | None
|
Called for every |
None
|
Bind optional notify and lifecycle callbacks.
Source code in src/terok_clearance/notifications/callback.py
notify(summary, body='', *, actions=(), timeout_ms=-1, hints=None, replaces_id=0, app_icon='', container_id='', container_name='', project='', task_id='', task_name='')
async
¶
Record the notification and invoke the on_notify hook.
Returns a monotonically increasing ID, or replaces_id for updates.
Source code in src/terok_clearance/notifications/callback.py
on_action(notification_id, callback)
async
¶
Store the action callback for later invocation.
close(notification_id)
async
¶
disconnect()
async
¶
invoke_action(notification_id, action_key)
¶
Invoke the stored callback for a user verdict.
This is the entry point for consumers that handle user input
(Allow/Deny) and need to route the decision back through
EventSubscriber to the D-Bus Verdict/Resolve method.
Source code in src/terok_clearance/notifications/callback.py
on_container_started(container)
¶
Forward a ContainerStarted lifecycle event to the consumer hook.
on_container_exited(container, reason)
¶
Forward a ContainerExited lifecycle event to the consumer hook.
on_shield_up(container)
¶
on_shield_down(container)
¶
Forward a ShieldDown signal (partial bypass) to the consumer hook.
on_shield_down_all(container)
¶
Forward a ShieldDownAll signal (full bypass) to the consumer hook.