Skip to main content

Module audit_stream

Module audit_stream 

Source
Expand description

Optional audit-stream-py producer. Gated behind the audit-stream Cargo feature so the core toolkit stays HTTP-free. Optional audit-stream-py producer.

When the audit-stream Cargo feature is enabled and the AUDIT_STREAM_URL env var is set, an AuditingBreaker fires governance events on every circuit-breaker state transition worth recording:

  • breaker_opened — closed/half-open → open. The “we just stopped trusting a downstream” signal.
  • breaker_recovered — half-open → closed. The “downstream looks healthy again” signal.

Manual AuditingBreaker::trip / AuditingBreaker::reset also fire when they cause a real state change.

Same opt-in pattern as the other Rust producers (hash-attestation, incident-correlation, aeo-graph-explorer). Identical env-var contract:

  • AUDIT_STREAM_URL — base URL, e.g. http://audit.local:8093
  • AUDIT_STREAM_TIMEOUT_S — per-call timeout, default 2.5s

Best-effort. Failures are logged to stderr and swallowed — an audit-stream outage must never block a call gated by the breaker.

Structs§

AuditingBreaker
Wraps a CircuitBreaker with a name + audit-stream client so that state transitions fan out as governance events.

Constants§

DEFAULT_TIMEOUT_S
Default per-call timeout when AUDIT_STREAM_TIMEOUT_S is unset.

Functions§

base_url
Stripped audit-stream base URL, or None when disabled.
emit
Fire one event. Silent no-op when AUDIT_STREAM_URL is unset.
is_enabled
True when AUDIT_STREAM_URL is set to a non-empty value.
timeout
Configured per-call timeout. Defaults to 2.5 seconds.