outputs

package
v0.0.0-...-5ddf7d0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_BATCH_SIZE = 1000
View Source
const DEFAULT_FLUSH_INTERVAL = time.Millisecond * 100

Variables

This section is empty.

Functions

func HasConstructorFor

func HasConstructorFor(s string) bool

func NewSocketOutput

func NewSocketOutput(c SocketOutputConfig) *socketOutput

func StartOutputter

func StartOutputter(name string, inputChan clogger.MessageChannel, send Outputter, bufferChannel clogger.MessageChannel)

StartOutputter starts up a go routine that handles all the input to the given output + buffering etc

Types

type DevNullOutput

type DevNullOutput struct {
	SendConfig
}

func (*DevNullOutput) Close

func (d *DevNullOutput) Close(ctx context.Context) error

func (*DevNullOutput) FlushToOutput

func (d *DevNullOutput) FlushToOutput(ctx context.Context, messages *clogger.MessageBatch) (OutputResult, error)

FlushToOutput takes a buffer of messages, and pushes them somewhere

func (*DevNullOutput) GetSendConfig

func (d *DevNullOutput) GetSendConfig() SendConfig

type FileOutput

type FileOutput struct {
	SendConfig
	// contains filtered or unexported fields
}

func NewFileOutput

func NewFileOutput(conf FileOutputConfig) (*FileOutput, error)

func (*FileOutput) Close

func (f *FileOutput) Close(ctx context.Context) error

func (*FileOutput) FlushToOutput

func (f *FileOutput) FlushToOutput(ctx context.Context, messages *clogger.MessageBatch) (OutputResult, error)

func (*FileOutput) GetSendConfig

func (f *FileOutput) GetSendConfig() SendConfig

type FileOutputConfig

type FileOutputConfig struct {
	SendConfig
	Path string
}

type OutputResult

type OutputResult int
const (
	// OUTPUT_SUCCESS indicates that the data was sucessfully sent to the output
	OUTPUT_SUCCESS OutputResult = iota

	// OUTPUT_TRANSIENT_FAILURE indicates that we failed to send data to the output, but should retry (with exponential backoff)
	OUTPUT_TRANSIENT_FAILURE

	// OUTPUT_LONG_FAILURE indicates that we failed to send data to the output and we should
	// buffer it to the buffer destination, if configured - this failure is likely to take a while to resolve
	OUTPUT_LONG_FAILURE
)

func (OutputResult) ToString

func (o OutputResult) ToString() string

type Outputter

type Outputter interface {
	// GetSendConfig returns the base send config of this Outputter
	GetSendConfig() SendConfig

	// FlushToOutput takes a buffer of messages, and pushes them somewhere
	FlushToOutput(ctx context.Context, messages *clogger.MessageBatch) (OutputResult, error)

	Close(ctx context.Context) error
}

An Outputter is a thing that can take messages and push them somewhere else

func Construct

func Construct(name string, config map[string]string) (Outputter, error)

type RetryConfig

type RetryConfig struct {
	MaxBackOffTries int
	BufferChannel   clogger.MessageChannel
	// contains filtered or unexported fields
}

type SendConfig

type SendConfig struct {
	// FlushInterval is the maximum time to buffer messages before outputting
	FlushInterval time.Duration

	// BatchSize is the maximum number of messages to store in the buffer before outputting
	BatchSize int

	// Formatter is the method that converts Messages into byte streams to be piped downstream
	Formatter format.Formatter
}

SendConfig is a config that specifies the base fields for all outputs

func NewSendConfigFromRaw

func NewSendConfigFromRaw(rawConf map[string]string) (SendConfig, error)

NewSendConfigFromRaw is a convenience method to construct SendConfigs from raw configs that might have been loaded from things like the config file

type Sender

type Sender struct {
	SendConfig
	RetryConfig
	// contains filtered or unexported fields
}

Sender encapsulates the functionality that all Outputters get for free i.e. Buffering

func NewSender

func NewSender(name string, logic Outputter) *Sender

func (*Sender) Flush

func (s *Sender) Flush(ctx context.Context, final bool)

Flush flushes the current buffer to the output stream

func (*Sender) QueueMessages

func (s *Sender) QueueMessages(ctx context.Context, batch *clogger.MessageBatch)

QueueMessages takes the given messages and appends them to the buffer, flushing as necessary

type SocketOutputConfig

type SocketOutputConfig struct {
	SendConfig
	ListenAddr string
	TLS        *clogger.TLSConfig
	Type       SocketOutputType
}

type SocketOutputType

type SocketOutputType int
const (
	UNIX_SOCKET_OUTPUT SocketOutputType = iota
	TCP_SOCKET_OUTPUT
)

func (SocketOutputType) ToString

func (s SocketOutputType) ToString() string

type StdOutputter

type StdOutputter struct {
	SendConfig
}

StdOutputter is an Outputter that takes messages from the input stream and pushes them to stdout (fd 0)

func NewStdOutputter

func NewStdOutputter(conf StdOutputterConfig) (*StdOutputter, error)

NewStdOutputter constructs a new StdOutputter from the given Config

func (*StdOutputter) Close

func (s *StdOutputter) Close(ctx context.Context) error

func (*StdOutputter) FlushToOutput

func (s *StdOutputter) FlushToOutput(ctx context.Context, messages *clogger.MessageBatch) (OutputResult, error)

func (*StdOutputter) GetSendConfig

func (s *StdOutputter) GetSendConfig() SendConfig

type StdOutputterConfig

type StdOutputterConfig struct {
	SendConfig
}

StdOutputterConfig is a shim around SendConfig for now mainly so that we can extend it in the future if necessary

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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