sink

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package sink defines where classified records go: stdout, files, review queues, downstream pipelines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Record         domain.Record
	Classification domain.Classification
}

Entry is one record/classification pair captured by InMemory.

type InMemory

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

InMemory is a Sink that collects everything written to it, for tests and wiring examples.

func NewInMemory

func NewInMemory() *InMemory

NewInMemory returns an empty collecting Sink.

func (*InMemory) Close

func (s *InMemory) Close() error

Close implements Sink.

func (*InMemory) Entries

func (s *InMemory) Entries() []Entry

Entries returns a copy of everything written so far, in order, so callers cannot mutate the sink's state.

func (*InMemory) Write

Write implements Sink.

type Router

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

Router is a Sink that dispatches each record to a per-category Sink, falling back to a default Sink for categories with no route. Because it is itself a Sink, the engine and the CLI use it unchanged.

func NewRouter

func NewRouter(fallback Sink, routes map[string]Sink) *Router

NewRouter returns a Router that sends a record to the Sink mapped to its classification Category, or to fallback when no category matches. A nil route Sink drops records of that category; a nil fallback drops records with an unrouted category.

func (*Router) Close

func (r *Router) Close() error

Close closes every underlying Sink, returning the first error. A Sink shared by several categories is closed more than once, which the idempotent Close contract allows.

func (*Router) Write

func (r *Router) Write(ctx context.Context, rec domain.Record, c domain.Classification) error

Write implements Sink, dispatching on the classification's Category.

type Sink

type Sink interface {
	// Write delivers one classified record.
	Write(ctx context.Context, r domain.Record, c domain.Classification) error
	// Close flushes and releases underlying resources. Safe to call more
	// than once.
	Close() error
}

Sink consumes records together with their classification.

Directories

Path Synopsis
Package jsonl implements sink.Sink as JSON Lines: one JSON object per classified record, the pipe-friendly lingua franca of log tooling.
Package jsonl implements sink.Sink as JSON Lines: one JSON object per classified record, the pipe-friendly lingua franca of log tooling.

Jump to

Keyboard shortcuts

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