utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWSFlush = errors.New("unable to flush write stream")

Functions

This section is empty.

Types

type BufferedWriteSyncer

type BufferedWriteSyncer struct {
	// WS is the WriteSyncer around which BufferedWriteSyncer will buffer
	// writes.
	//
	// This field is required.
	WS zapcore.WriteSyncer

	// Size specifies the maximum amount of data the writer will buffered
	// before flushing.
	//
	// Defaults to 256 kB if unspecified.
	Size int

	// FlushInterval specifies how often the writer should flush data if
	// there have been no writes.
	//
	// Defaults to 30 seconds if unspecified.
	FlushInterval time.Duration

	// Clock, if specified, provides control of the source of time for the
	// writer.
	//
	// Defaults to the system clock.
	Clock zapcore.Clock
	// contains filtered or unexported fields
}

buffers writes in-memory before flushing them to a wrapped WriteSyncer after reaching some limit, or at some fixed interval--whichever comes first.

func (*BufferedWriteSyncer) Flush

func (s *BufferedWriteSyncer) Flush() error

Flush with timeout

func (*BufferedWriteSyncer) Stop

func (s *BufferedWriteSyncer) Stop() (err error)

Stop closes the buffer, cleans up background goroutines, and flushes remaining unwritten data.

func (*BufferedWriteSyncer) Sync

func (s *BufferedWriteSyncer) Sync() error

Sync flushes buffered log data into disk directly.

func (*BufferedWriteSyncer) Write

func (s *BufferedWriteSyncer) Write(bs []byte) (int, error)

Write writes log data into buffer syncer directly, multiple Write calls will be batched, and log data will be flushed to disk when the buffer is full or periodically.

Jump to

Keyboard shortcuts

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