Skip to main content

Module sink

Module sink 

Source
Expand description

Wire codec and sink trait sub-modules. Consumers implementing a custom Sink or reading/writing envelopes on the wire previously had to depend on obs-core directly; obs-kit re-exports these so obs-kit = "0.2" is the only runtime dep needed. Spec § 5.1. Sinks consume ScrubbedEnvelope and ship it to a destination (stdout, NDJSON file, OTLP, ClickHouse, etc.).

Phase-3 surface (impl-plan tasks 3.7 / 3.12 + 3.1 worker pool):

  • Sink trait + flush / shutdown lifecycle.
  • NoopSink, InMemorySink (test harness).
  • StdoutSink with all four FormatterStyles.
  • NdjsonFileSink over RollingFileWriter.
  • MakeWriter family: StdoutWriter, StderrWriter, LevelSplitWriter, TeeWriter, RollingFileWriter, NonBlockingWriter.

Modules§

fanout
FanOutSink — deliver one envelope to N child sinks.

Structs§

ErasedWriter
Erased Box<dyn Write + Send> so LevelSplitWriter::Writer can be a single concrete type (the trait associated type is fixed, can’t be match-ed at the type level).
FanOutSink
Multiplex a single tier’s output across N sinks.
InMemoryHandle
Stable handle to an InMemorySink. Clone-safe; share across threads.
InMemorySink
Test sink: collects envelopes into a bounded ring buffer.
LevelSplitWriter
Composes two writers — INFO+ goes through low, WARN+ through high. The conventional shape for cargo binaries.
NdjsonFileSink
File sink that writes envelopes as JSON lines to the underlying MakeWriter. Buffers a Mutex<ErasedWriter> per batch to avoid re-opening files for every event.
NonBlockingHandle
Per-batch handle. Buffers bytes, flushes to the bg sender on flush() / Drop.
NonBlockingWriter
Wraps a MakeWriter with a background thread + bounded mpsc::SyncSender channel. Overflow drops the line and increments the dropped counter. Spec 20 § 3.5.
NoopSink
A sink that drops every envelope.
RollingFileHandle
Handle returned per-batch by RollingFileWriter. Each write_all rotates if the policy demands it.
RollingFileWriter
Rolling file writer with size + time policies. Spec 20 § 3.4.
RollingFileWriterBuilder
Builder for RollingFileWriter.
StderrWriter
Writes to stderr.
StdoutSink
Stdout / writer-backed sink.
StdoutWriter
Writes to stdout.
TeeWriter
Tee writer — writes to both branches.
WorkerGuard
Returned alongside NonBlockingWriter; flushes + joins the bg thread on drop.

Enums§

FormatterStyle
Output style for StdoutSink. See spec 20 § 3.6.
RollingPolicy
Rolling policy. Spec 20 § 3.4.

Traits§

MakeWriter
A factory that yields one io::Write per batch. Cheap to call. Spec 20 § 3.3.
Sink
A delivery destination. Called from per-tier worker tasks, never on the emit thread.

Type Aliases§

SinkFut
Pinned future returned by Sink::flush / Sink::shutdown. Spec 11 § 4.