logio

package
v0.18.49 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package logio decouples log production from the log sink.

Motivation (2026-08-14, frozen-spin/quiet-stall stall family): the worker logs to stderr, which in the benchmark deploy is a pipe into journald. When journald stalls, the 64KB pipe fills, the next slog write blocks WHILE HOLDING the handler mutex, and every goroutine that logs parks behind it — a whole-process freeze that self-heals in one burst when journald catches up (validation run 20260814-002639: 190s freeze on one worker, liveness markers stopped, coordinator saw a 36-result burst on recovery). Execution must never be gated on the log sink.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncWriter

type AsyncWriter struct {
	// contains filtered or unexported fields
}

AsyncWriter is an io.Writer that hands records to a background drainer through a bounded channel. When the buffer is full, Write drops the record and counts it instead of blocking. Dropped totals are surfaced in-band by the drainer (at most once per second) so the log stream itself records the loss.

func NewAsyncWriter

func NewAsyncWriter(sink io.Writer, depth int) *AsyncWriter

NewAsyncWriter starts the drainer. depth is the buffered record count; at a few hundred bytes per record, 8192 records ≈ 2-3 MB and absorbs many minutes of normal log volume during a sink stall.

func (*AsyncWriter) Close

func (a *AsyncWriter) Close() error

Close stops accepting writes, drains the buffer to the sink, and returns. Safe to call once; further Writes after Close are dropped.

func (*AsyncWriter) Dropped

func (a *AsyncWriter) Dropped() uint64

Dropped returns the number of records dropped so far.

func (*AsyncWriter) Write

func (a *AsyncWriter) Write(p []byte) (int, error)

Write never blocks on the sink: it copies p (slog reuses its buffer) and enqueues, dropping on overflow. Always reports success to the caller — a dropped log line must not fail the operation that logged. The RLock guards the enqueue against a concurrent Close (send on closed channel); it is uncontended in steady state.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL