decoder

package
v0.0.0-...-914b764 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

type Decoder struct {
	InputChan  chan *Input
	OutputChan chan *Output
	// contains filtered or unexported fields
}

Decoder splits raw data into lines and passes them to a lineHandler that emits outputs

func InitializeDecoder

func InitializeDecoder(source *config.LogSource, parser parser.Parser) *Decoder

InitializeDecoder returns a properly initialized Decoder

func New

func New(InputChan chan *Input, OutputChan chan *Output, lineHandler LineHandler, contentLenLimit int, matcher EndLineMatcher) *Decoder

New returns an initialized Decoder

func NewDecoderWithEndLineMatcher

func NewDecoderWithEndLineMatcher(source *config.LogSource, parser parser.Parser, matcher EndLineMatcher) *Decoder

NewDecoderWithEndLineMatcher initialize a decoder with given endline strategy.

func (*Decoder) Start

func (d *Decoder) Start()

Start starts the Decoder

func (*Decoder) Stop

func (d *Decoder) Stop()

Stop stops the Decoder

type EndLineMatcher

type EndLineMatcher interface {
	// Match takes the existing bytes and the bytes to be appended, returns
	// true if the combination matches the end of line condition.
	Match(exists []byte, appender []byte, start int, end int) bool
}

EndLineMatcher defines the criterion to whether to end a line or not.

type Input

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

Input represents a chunk of line.

func NewInput

func NewInput(content []byte) *Input

NewInput returns a new input.

type LineHandler

type LineHandler interface {
	Handle(content []byte)
	Start()
	Stop()
}

LineHandler handles raw lines to form structured lines

type MultiLineHandler

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

MultiLineHandler makes sure that multiple lines from a same content are properly put together.

func NewMultiLineHandler

func NewMultiLineHandler(outputChan chan *Output, newContentRe *regexp.Regexp, flushTimeout time.Duration, parser parser.Parser, lineLimit int) *MultiLineHandler

NewMultiLineHandler returns a new MultiLineHandler.

func (*MultiLineHandler) Handle

func (h *MultiLineHandler) Handle(content []byte)

Handle forward lines to lineChan to process them.

func (*MultiLineHandler) Start

func (h *MultiLineHandler) Start()

Start starts the handler.

func (*MultiLineHandler) Stop

func (h *MultiLineHandler) Stop()

Stop stops the handler.

type Output

type Output struct {
	Content    []byte
	Status     string
	RawDataLen int
	Timestamp  string
}

Output represents a structured line.

func NewOutput

func NewOutput(content []byte, status string, rawDataLen int, timestamp string) *Output

NewOutput returns a new output.

type SingleLineHandler

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

SingleLineHandler takes care of tracking the line length and truncating them when they are too long.

func NewSingleLineHandler

func NewSingleLineHandler(outputChan chan *Output, parser parser.Parser, lineLimit int) *SingleLineHandler

NewSingleLineHandler returns a new SingleLineHandler.

func (*SingleLineHandler) Handle

func (h *SingleLineHandler) Handle(content []byte)

Handle puts all new lines into a channel for later processing.

func (*SingleLineHandler) Start

func (h *SingleLineHandler) Start()

Start starts the handler.

func (*SingleLineHandler) Stop

func (h *SingleLineHandler) Stop()

Stop stops the handler.

Jump to

Keyboard shortcuts

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