Documentation
¶
Overview ¶
Package webhook delivers best-effort HTTP notifications on Trace session lifecycle events. Delivery is non-blocking and fail-open: a webhook that is slow, unreachable, or returns an error never propagates back to the caller and never fails a session. Failures are logged at WARN and dropped.
Index ¶
Constants ¶
const ( EventSessionStart = "session_start" EventCheckpointCreated = "checkpoint_created" EventSessionEnd = "session_end" EventError = "error" )
Lifecycle event names. These are the canonical strings used both in the delivered payload's "event" field and in WebhookConfig.Events filtering.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
Notifier delivers events to a set of configured webhook endpoints.
func LoadNotifier ¶
LoadNotifier loads webhook config from Trace settings and returns a Notifier. Returns nil (a valid no-op) when settings cannot be loaded or no webhooks are configured — webhook delivery must never block on configuration errors.
func NewNotifier ¶
func NewNotifier(cfg *settings.WebhookConfig) *Notifier
NewNotifier builds a Notifier from the given config. It returns nil when no endpoints are configured, so callers can treat a nil *Notifier as a no-op (every method is nil-safe).
func (*Notifier) Notify ¶
Notify delivers an event to every configured endpoint. It is best-effort and never returns an error: failures are logged and dropped. The payload is the JSON object {event, session_id, timestamp, ...extra}. Calling on a nil Notifier is a no-op.
Delivery runs synchronously against the per-POST timeout so the caller can reason about the upper bound. Callers on a hot path that cannot tolerate even the bounded wait should use NotifyAsync.
func (*Notifier) NotifyAsync ¶
NotifyAsync delivers an event on a detached goroutine and returns immediately, so even the bounded per-POST wait stays off the caller's path. It uses context.Background so a cancelled caller context does not abort in-flight delivery. Best-effort; failures are logged.