outbox

package
v0.0.1-dev.137 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package outbox is the agent's per-node buffer for logs and events destined for remote sinks (RuneSight, CloudWatch, Datadog).

The outbox is intentionally simple in RUNE-032: a bounded in-memory channel with a drop-oldest policy on overflow. Persistence and pluggable sinks land with the observability work in Release 4. The abstraction exists now so subsystems built in the next networking tickets (data plane, DNS, policy) write to a stable interface that will not change when the real outbox lands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Kind      Kind
	Timestamp time.Time
	Source    string                 // subsystem name
	Message   string                 // for KindLog; short summary for KindEvent
	Fields    map[string]interface{} // structured fields
}

Entry is a single buffered item.

type Kind

type Kind uint8

Kind classifies an outbox entry.

const (
	// KindLog is a log line emitted by an agent subsystem.
	KindLog Kind = iota + 1
	// KindEvent is a structured event (policy drop, endpoint change,
	// ingress lifecycle, etc.).
	KindEvent
)

type Outbox

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

Outbox is a bounded, thread-safe FIFO of Entries. Producers call Push; consumers (sink writers) call Drain in batches.

func New

func New(capacity int, logger log.Logger) *Outbox

New constructs an Outbox with the given capacity. capacity <= 0 defaults to 1024.

func (*Outbox) Close

func (o *Outbox) Close()

Close marks the outbox as closed. Subsequent Pushes are dropped silently. Drain still returns any entries already buffered.

func (*Outbox) Drain

func (o *Outbox) Drain(max int) []Entry

Drain removes up to max entries (oldest first) and returns them. If the outbox is empty, Drain returns nil. max <= 0 drains everything.

func (*Outbox) Dropped

func (o *Outbox) Dropped() uint64

Dropped returns the cumulative count of evicted entries.

func (*Outbox) Len

func (o *Outbox) Len() int

Len returns the current buffer depth. Useful for metrics.

func (*Outbox) Push

func (o *Outbox) Push(e Entry)

Push adds e to the outbox. If the outbox is full, the oldest entry is evicted and a drop counter is incremented. Push never blocks.

Push on a closed Outbox is a no-op.

Jump to

Keyboard shortcuts

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