Skip to main content

auths_telemetry/
ports.rs

1//! Telemetry sink port definition.
2
3/// Synchronous, fire-and-forget sink for structured telemetry payloads.
4///
5/// Implementations are responsible for persistence, buffering, and flushing.
6/// `emit()` must never block the caller; defer I/O to a background thread or
7/// accumulate in memory. `flush()` blocks until all previously-emitted payloads
8/// have been persisted.
9///
10/// Usage:
11/// ```ignore
12/// use auths_telemetry::ports::EventSink;
13///
14/// struct NullSink;
15/// impl EventSink for NullSink {
16///     fn emit(&self, _payload: &str) {}
17///     fn flush(&self) {}
18/// }
19/// ```
20pub trait EventSink: Send + Sync + 'static {
21    /// Emit a JSON-serialized event payload. Must not block.
22    fn emit(&self, payload: &str);
23
24    /// Block until all previously-emitted payloads have been written.
25    fn flush(&self);
26}