Help us shape the future of Go! Take the 2026 Go Developer Survey

workerpipe

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package workerpipe (ADR-0168): funcd's end of a worker's raw stdout and stderr, read as written into a bounded queue for funclog and a bounded tail. Both drivers use it; it imports no container or observability package.

Index

Constants

View Source
const (
	DefaultLineBytes  = 64 << 10  // a longer line is split into lines of this size
	DefaultQueueBytes = 256 << 10 // the queue for funclog; half of it per stream
	DefaultTailBytes  = 64 << 10  // the tail Runtime.Logs returns
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	LineBytes, QueueBytes, TailBytes int
	Logger                           *slog.Logger
}

Options sizes an Output; a zero size is its default and a nil Logger is slog.Default().

type Output

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

Output holds funcd's end of one worker run's stdout and stderr.

func New

func New(o Options) *Output

New returns an Output sized by o.

func (*Output) Close

func (o *Output) Close()

Close never blocks and is idempotent: once every Drain has returned it files the last partial lines, Warns about any drop not yet reported, and closes Done. Writes after Close are dropped and counted.

func (*Output) Done

func (o *Output) Done() <-chan struct{}

Done is closed once Close ran and every Drain returned.

func (*Output) Drain

func (o *Output) Drain(s Stream, r io.ReadCloser)

Drain reads r on its own goroutine until EOF or an error, then closes r. A Drain that starts after Close still runs; Done waits for every Drain.

func (*Output) Dropped

func (o *Output) Dropped() uint64

Dropped is how many lines were dropped.

func (*Output) Reader

func (o *Output) Reader(s Stream) StreamReader

Reader returns s's "\n"-ended lines, queued from the first call; it returns EOF once the Output is closed, drained and the queue is empty.

func (*Output) Tail

func (o *Output) Tail() io.ReadCloser

Tail returns a copy of the last TailBytes of output, the oldest line evicted first: stdout's lines, then stderr's.

func (*Output) Writer

func (o *Output) Writer(s Stream) io.Writer

Writer returns a writer for s that never blocks and always returns len(p), nil: a line its stream's queue budget cannot hold is dropped and counted, and so is every line written after Close.

type Stream

type Stream int

Stream names one of a worker's two raw output streams.

const (
	Stdout Stream = 1
	Stderr Stream = 2
)

type StreamReader

type StreamReader interface {
	io.ReadCloser
	CloseRead() error
}

StreamReader is one stream's queued lines; CloseRead is the Shutdown seal: EOF after the queued lines.

Jump to

Keyboard shortcuts

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