Documentation ¶
Overview ¶
Package buffer provides a generic buffer or batching mechanism for flushing entries at a given size or interval, useful for cases such as batching log events.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultFlushInterval = time.Second * 30
DefaultFlushInterval is the default flush interval.
var DefaultFlushTimeout = time.Second * 15
DefaultFlushTimeout is the default flush timeout.
var DefaultMaxEntries = 250
DefaultMaxEntries is the default max entries limit.
var DefaultMaxRetries = 3
DefaultMaxRetries is the default max retries limit.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is used to batch entries.
func (*Buffer) Close ¶
func (b *Buffer) Close()
Close flushes any pending entries, and waits for flushing to complete. This method should be called before exiting your program to ensure entries have flushed properly.
type ErrorFunc ¶
type ErrorFunc func(error)
ErrorFunc is the error callback function used to report flushing errors, called when flushing fails and MaxRetries has exceeded on temporary errors.
type Option ¶
type Option func(*Buffer)
Option function.
func WithErrorHandler ¶
WithErrorHandler sets the function handling errors.
func WithFlushHandler ¶
WithFlushHandler sets the function handling flushes.
func WithFlushInterval ¶ added in v1.0.1
WithFlushInterval sets the interval at which events are periodically flushed.
func WithFlushTimeout ¶ added in v1.0.1
WithFlushTimeout sets the flush timeout.
func WithMaxEntries ¶ added in v1.0.1
WithMaxEntries sets the maximum number of entries before flushing.
func WithMaxRetries ¶ added in v1.0.1
WithMaxRetries sets the maximum number of retries for temporary flush errors.