outputlimit

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package outputlimit supplies New for private retained-output quotas, not codec allocation or atomic publication. Buffers are mutable and not concurrency-safe; Bytes aliases their storage. No external handles or workers are owned.

Index

Constants

This section is empty.

Variables

View Source
var ErrLimit = errors.New("encoded output exceeds size limit")

ErrLimit identifies encoded output that exceeds its configured byte limit.

Functions

This section is empty.

Types

type Buffer

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

Buffer is an io.Writer that retains at most its configured byte limit.

func New

func New(configured, fallback int64) (*Buffer, error)

New rejects negative configured limits and uses fallback when configured is zero. Callers must provide a nonnegative fallback; it is not validated here. Construction does not preallocate the entire quota.

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

Bytes returns an alias of retained output; later writes can invalidate or modify it. Clone when an independent snapshot is required.

func (*Buffer) Len

func (b *Buffer) Len() int

Len returns the number of retained bytes.

func (*Buffer) Write

func (b *Buffer) Write(payload []byte) (int, error)

Write retains p when it fits and otherwise returns ErrLimit without retaining bytes beyond the configured maximum.

Jump to

Keyboard shortcuts

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