Skip to main content

Module webhooks

Module webhooks 

Source
Expand description

§Module: Webhook Notifications

§Responsibility

Delivers structured JSON event notifications to one or more configured webhook URLs when important pipeline events occur:

EventTrigger
WebhookEvent::CircuitBreakerStateChangeCircuit breaker transitions CLOSED→OPEN, OPEN→HALF-OPEN, etc.
WebhookEvent::BudgetThresholdExceededSpend crosses a configured threshold
WebhookEvent::AnomalyDetectedAnomaly detector raises an alert
WebhookEvent::ThroughputDropPipeline 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§

WebhookConfig
Configuration for a single webhook endpoint.
WebhookDispatcher
Sends webhook events to all configured endpoints.
WebhookPayload
The JSON body delivered to webhook endpoints.

Enums§

CircuitBreakerState
State of a circuit breaker (mirrored here to avoid importing enhanced::).
WebhookError
Errors produced by the webhook dispatcher.
WebhookEvent
A pipeline event that triggers webhook delivery.

Functions§

budget_exceeded_event
Build a WebhookEvent::BudgetThresholdExceeded event.
circuit_breaker_event
Build a WebhookEvent::CircuitBreakerStateChange event.
throughput_drop_event
Build a WebhookEvent::ThroughputDrop event.