Expand description
§Module: Webhook Notifications
§Responsibility
Delivers structured JSON event notifications to one or more configured webhook URLs when important pipeline events occur:
| Event | Trigger |
|---|---|
WebhookEvent::CircuitBreakerStateChange | Circuit breaker transitions CLOSED→OPEN, OPEN→HALF-OPEN, etc. |
WebhookEvent::BudgetThresholdExceeded | Spend crosses a configured threshold |
WebhookEvent::AnomalyDetected | Anomaly detector raises an alert |
WebhookEvent::ThroughputDrop | Pipeline throughput drops >50% compared to recent baseline |
Each event is delivered with a context JSON payload via HTTP POST.
§Delivery guarantees
- At-most-once: no retry on failure (logged as warning)
- Non-blocking: delivery is async; the caller never blocks
- Circuit-breaker aware: a per-webhook soft-disable prevents thundering herd when a webhook URL is consistently unreachable (≥5 consecutive failures causes a 60-second backoff)
§Usage
ⓘ
let dispatcher = WebhookDispatcher::new(vec![
WebhookConfig { url: "https://hooks.example.com/pipeline".into(), ..Default::default() },
])?;
dispatcher.dispatch(WebhookEvent::CircuitBreakerStateChange {
worker: "openai".into(),
from: CircuitBreakerState::Closed,
to: CircuitBreakerState::Open,
failure_count: 5,
}).await;Structs§
- Webhook
Config - Configuration for a single webhook endpoint.
- Webhook
Dispatcher - Sends webhook events to all configured endpoints.
- Webhook
Payload - The JSON body delivered to webhook endpoints.
Enums§
- Circuit
Breaker State - State of a circuit breaker (mirrored here to avoid importing enhanced::).
- Webhook
Error - Errors produced by the webhook dispatcher.
- Webhook
Event - A pipeline event that triggers webhook delivery.
Functions§
- budget_
exceeded_ event - Build a
WebhookEvent::BudgetThresholdExceededevent. - circuit_
breaker_ event - Build a
WebhookEvent::CircuitBreakerStateChangeevent. - throughput_
drop_ event - Build a
WebhookEvent::ThroughputDropevent.