Skip to main content

Crate af_notify

Crate af_notify 

Source
Expand description

af-notify — notification dispatcher + transport seam. Port of the reusable core of agent_core/notifications/.

The governance rule that carries over: every outbound message goes through the dispatcher, never a raw api.telegram.org/... POST. A product builds a typed Notification (transport-agnostic blocks) and dispatches it; each Sender renders the blocks its own way (a chat transport flattens to text, a rich transport keeps structure).

Transports (Telegram / email / Discord) are pluggable adapters that implement Sender — the core never depends on a specific provider.

use af_notify::{Block, Dispatcher, LogSender, Notification};
use std::sync::Arc;

let mut d = Dispatcher::new();
d.register(Arc::new(LogSender));
let notif = Notification::new()
    .title("Run finished")
    .block(Block::text("Your workflow completed."))
    .block(Block::fields(vec![("duration".into(), "1.2s".into())]));
d.dispatch("log", "ops", &notif).await.unwrap();

Structs§

Dispatcher
Routes notifications to registered senders by channel name.
LogSender
Default sender: emits the rendered notification to the log. Useful in dev and as the reference transport.
NewOutboxItem
A notification to enqueue.
Notification
A transport-agnostic notification.
OutboxItem
A durably queued notification claimed by a worker.

Enums§

Block
One piece of a notification. Transport-agnostic; senders decide how to render each block.
NotifyError
Failure while dispatching a notification.

Traits§

DurableOutbox
Lease-fenced durable queue between producers and transport senders.
Sender
A transport. The name is the channel key callers dispatch to ("telegram", "email", "log", …).