outputguard

package
v0.82.2 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package outputguard serializes protocol and print output through one stateful writer boundary.

Index

Constants

View Source
const DefaultRetryDelay = 10 * time.Millisecond

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	RetryDelay time.Duration
}

Options configures Writer retry behavior.

type Writer

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

Writer owns an output destination, serializes complete logical writes, and retains the first permanent output error. Synchronous io.Writer calls provide the backpressure boundary; Flush is a barrier for all preceding writes.

func New

func New(dst io.Writer, options Options) *Writer

New returns a serialized writer for dst. A nil destination discards output.

func (*Writer) Err

func (w *Writer) Err() error

Err returns the first permanent write or flush error.

func (*Writer) Flush

func (w *Writer) Flush() error

Flush waits for preceding writes, flushes buffered destinations when supported, and returns the first permanent output error.

func (*Writer) FlushContext

func (w *Writer) FlushContext(ctx context.Context) error

FlushContext is Flush with cancellation support while retrying a transient flusher error.

func (*Writer) Write

func (w *Writer) Write(data []byte) (int, error)

Write implements io.Writer. It does not return until the whole logical chunk has been accepted or a permanent error occurs.

func (*Writer) WriteContext

func (w *Writer) WriteContext(
	ctx context.Context,
	data []byte,
) (int, error)

WriteContext is Write with cancellation support while retrying transient output pressure.

func (*Writer) WriteString

func (w *Writer) WriteString(text string) (int, error)

WriteString writes one logical text chunk without allowing concurrent chunks to interleave.

func (*Writer) WriteStringContext

func (w *Writer) WriteStringContext(
	ctx context.Context,
	text string,
) (int, error)

WriteStringContext is WriteString with cancellation support.

Jump to

Keyboard shortcuts

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