buffer

package
v0.9.14 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer interface {
	Flush(context.Context) error
	Add(interface{}, int) error
	AddWait(context.Context, interface{}, int) error
	SetHandler(BundleHandler)
	Process(context.Context, *entry.Entry) error
}

Buffer is an entity that buffers log entries to an operator

type BundleHandler

type BundleHandler interface {
	ProcessMulti(context.Context, []*entry.Entry) error
	Logger() *zap.SugaredLogger
}

BundleHandler is an interface that process multiple entries

type Config

type Config struct {
	BufferType           string            `json:"type,omitempty"                   yaml:"type,omitempty"`
	DelayThreshold       operator.Duration `json:"delay_threshold,omitempty"        yaml:"delay_threshold,omitempty"`
	BundleCountThreshold int               `json:"bundle_count_threshold,omitempty" yaml:"buffer_count_threshold,omitempty"`
	BundleByteThreshold  int               `json:"bundle_byte_threshold,omitempty"  yaml:"bundle_byte_threshold,omitempty"`
	BundleByteLimit      int               `json:"bundle_byte_limit,omitempty"      yaml:"bundle_byte_limit,omitempty"`
	BufferedByteLimit    int               `json:"buffered_byte_limit,omitempty"    yaml:"buffered_byte_limit,omitempty"`
	HandlerLimit         int               `json:"handler_limit,omitempty"          yaml:"handler_limit,omitempty"`
	Retry                RetryConfig       `json:"retry,omitempty"                  yaml:"retry,omitempty"`
}

Config is the configuration of a buffer

func NewConfig

func NewConfig() Config

func (*Config) Build

func (config *Config) Build() (Buffer, error)

Build will build a buffer from the supplied configuration

type MemoryBuffer

type MemoryBuffer struct {
	*bundler.Bundler
	// contains filtered or unexported fields
}

MemoryBuffer is a buffer that holds entries in memory

func NewMemoryBuffer

func NewMemoryBuffer(config *Config) *MemoryBuffer

NewMemoryBuffer will return a new memory buffer with the supplied configuration

func (*MemoryBuffer) Flush

func (m *MemoryBuffer) Flush(ctx context.Context) error

Flush will flush the memory buffer

func (*MemoryBuffer) NewExponentialBackOff

func (m *MemoryBuffer) NewExponentialBackOff() *backoff.ExponentialBackOff

NewExponentialBackOff will return a new exponential backoff for the memory buffer to use

func (*MemoryBuffer) Process

func (m *MemoryBuffer) Process(ctx context.Context, entry *entry.Entry) error

Process will add an entry to the current buffer

func (*MemoryBuffer) SetHandler

func (m *MemoryBuffer) SetHandler(handler BundleHandler)

SetHandler will set the handler of the memory buffer

type RetryConfig

type RetryConfig struct {
	InitialInterval     operator.Duration `json:"initial_interval,omitempty"     yaml:"initial_interval,omitempty"`
	RandomizationFactor float64           `json:"randomization_factor,omitempty" yaml:"randomization_factor,omitempty"`
	Multiplier          float64           `json:"multiplier,omitempty"           yaml:"multiplier,omitempty"`
	MaxInterval         operator.Duration `json:"max_interval,omitempty"         yaml:"max_interval,omitempty"`
	MaxElapsedTime      operator.Duration `json:"max_elapsed_time,omitempty"     yaml:"max_elapsed_time,omitempty"`
}

RetryConfig is the configuration of an entity that will retry processing after an error

func NewRetryConfig

func NewRetryConfig() RetryConfig

Jump to

Keyboard shortcuts

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