bpbuffer

package
v0.0.0-...-05bc493 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackpressureBuffer

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

Provides weak-reference behavior to enable auto-stop of workers

func NewBackpressureBuffer

func NewBackpressureBuffer(output *logwriter.Adapter, bufSize int, maxParWrites uint8,
	flags BackpressureBufferFlags, missFn MissedEventFunc,
) *BackpressureBuffer

func NewBackpressureBufferWithBypass

func NewBackpressureBufferWithBypass(output *logwriter.Adapter, bufSize int, maxParWrites uint8,
	flags BackpressureBufferFlags, missFn MissedEventFunc,
) *BackpressureBuffer

func (BackpressureBuffer) Close

func (p BackpressureBuffer) Close() error

func (BackpressureBuffer) Flush

func (p BackpressureBuffer) Flush() error

NB! Flush() may NOT be able to clean up whole buffer when there are too many pending writers

func (BackpressureBuffer) GetAvgWriteDuration

func (p BackpressureBuffer) GetAvgWriteDuration() time.Duration

func (BackpressureBuffer) IsLowLatencySupported

func (p BackpressureBuffer) IsLowLatencySupported() bool

func (BackpressureBuffer) LogLevelWrite

func (p BackpressureBuffer) LogLevelWrite(level logcommon.Level, b []byte) (n int, err error)

func (BackpressureBuffer) LowLatencyWrite

func (p BackpressureBuffer) LowLatencyWrite(level logcommon.Level, b []byte) (n int, err error)

func (BackpressureBuffer) SetAvgWriteDuration

func (p BackpressureBuffer) SetAvgWriteDuration(d time.Duration)

func (*BackpressureBuffer) StartWorker

The buffer requires a worker to scrap the buffer. Multiple workers are ok, but aren't necessary. Start of the worker will also attach a finalizer to the buffer.

func (BackpressureBuffer) Write

func (p BackpressureBuffer) Write(b []byte) (n int, err error)

type BackpressureBufferFlags

type BackpressureBufferFlags uint8
const (
	// Buffer content will not be flushed on fatal, instead a "missing X" message will be added.
	BufferDropOnFatal BackpressureBufferFlags = 1 << iota
	// Buffer may apply additional delay to writes done into a queue to equalize timings.
	// This mode requires either BufferTrackWriteDuration flag or use of SetAvgWriteDuration() externally.
	// This flag has no effect when bufferBypassForRegular is set.
	BufferWriteDelayFairness
	// With this flag the buffer will update GetAvgWriteDuration with every regular write.
	BufferTrackWriteDuration
	// When a worker is started, but all links to BackpressureBuffer were lost, then the worker will be stopped.
	// And with this flag present, the buffer (and its underlying output) will also be closed.
	BufferCloseOnStop
	// USE WITH CAUTION! This flag enables to use argument of Write([]byte) outside of the call.
	// This is AGAINST existing conventions and MUST ONLY be used when a writer's code is proprietary and never reuses the argument.
	BufferReuse
)

type MissedEventFunc

type MissedEventFunc func(missed int) (logcommon.Level, []byte)

Jump to

Keyboard shortcuts

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