Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Utf16leEOL is the bytes sequence for UTF-16 Little-Endian end-of-line char Utf16leEOL = []byte{'\n', 0x00} // Utf16beEOL is the bytes sequence for UTF-16 Big-Endian end-of-line char Utf16beEOL = []byte{0x00, '\n'} )
Functions ¶
This section is empty.
Types ¶
type BytesSequenceMatcher ¶ added in v0.9.0
type BytesSequenceMatcher struct {
// contains filtered or unexported fields
}
BytesSequenceMatcher defines the criterion to whether to end a line based on an arbitrary byte sequence
func NewBytesSequenceMatcher ¶ added in v0.9.0
func NewBytesSequenceMatcher(sequence []byte) *BytesSequenceMatcher
NewBytesSequenceMatcher Returns a new matcher based on custom bytes sequence
func (*BytesSequenceMatcher) Match ¶ added in v0.9.0
Match returns true whenever it finds a matching sequence at the end of append(exists, appender[start:end+1])
func (*BytesSequenceMatcher) SeparatorLen ¶ added in v0.9.0
func (b *BytesSequenceMatcher) SeparatorLen() int
SeparatorLen return the number of byte to ignore
type DecodedInput ¶ added in v0.9.0
type DecodedInput struct {
// contains filtered or unexported fields
}
DecodedInput represents a decoded line and the raw length
func NewDecodedInput ¶ added in v0.9.0
func NewDecodedInput(content []byte, rawDataLen int) *DecodedInput
NewDecodedInput returns a new decoded input.
type Decoder ¶
type Decoder struct {
InputChan chan *Input
OutputChan chan *Message
// contains filtered or unexported fields
}
Decoder splits raw data into lines and passes them to a lineParser that passes them to a lineHandler that emits outputs Input->[decoder]->[parser]->[handler]->Message
func InitializeDecoder ¶
InitializeDecoder returns a properly initialized Decoder
func New ¶
func New(InputChan chan *Input, OutputChan chan *Message, lineParser LineParser, 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.
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
SeparatorLen() int
}
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.
type LineHandler ¶
type LineHandler interface {
Handle(input *Message)
Start()
Stop()
}
LineHandler handles raw lines to form structured lines
type LineParser ¶ added in v0.9.0
type LineParser interface {
Handle(input *DecodedInput)
Start()
Stop()
}
LineParser e
type Message ¶ added in v0.9.0
type Message struct {
Content []byte
Status string
RawDataLen int
Timestamp string
IngestionTimestamp int64
}
Message represents a structured line.
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 *Message, newContentRe *regexp.Regexp, flushTimeout time.Duration, lineLimit int) *MultiLineHandler
NewMultiLineHandler returns a new MultiLineHandler.
func (*MultiLineHandler) Handle ¶
func (h *MultiLineHandler) Handle(input *Message)
Handle forward lines to lineChan to process them.
type MultiLineParser ¶ added in v0.9.0
type MultiLineParser struct {
// contains filtered or unexported fields
}
MultiLineParser makes sure that chunked lines are properly put together.
func NewMultiLineParser ¶ added in v0.9.0
func NewMultiLineParser(flushTimeout time.Duration, parser parser.Parser, lineHandler LineHandler, lineLimit int) *MultiLineParser
NewMultiLineParser returns a new MultiLineHandler.
func (*MultiLineParser) Handle ¶ added in v0.9.0
func (p *MultiLineParser) Handle(input *DecodedInput)
Handle forward lines to lineChan to process them.
func (*MultiLineParser) Start ¶ added in v0.9.0
func (p *MultiLineParser) Start()
Start starts the handler.
func (*MultiLineParser) Stop ¶ added in v0.9.0
func (p *MultiLineParser) Stop()
Stop stops the handler.
type NewLineMatcher ¶ added in v0.9.0
type NewLineMatcher struct {
EndLineMatcher
}
NewLineMatcher implements EndLineMatcher for line ending with '\n'
func (*NewLineMatcher) SeparatorLen ¶ added in v0.9.0
func (n *NewLineMatcher) SeparatorLen() int
SeparatorLen returns the length of the line separator
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 *Message, lineLimit int) *SingleLineHandler
NewSingleLineHandler returns a new SingleLineHandler.
func (*SingleLineHandler) Handle ¶
func (h *SingleLineHandler) Handle(input *Message)
Handle puts all new lines into a channel for later processing.
type SingleLineParser ¶ added in v0.9.0
type SingleLineParser struct {
// contains filtered or unexported fields
}
SingleLineParser makes sure that multiple lines from a same content are properly put together.
func NewSingleLineParser ¶ added in v0.9.0
func NewSingleLineParser(parser parser.Parser, lineHandler LineHandler) *SingleLineParser
NewSingleLineParser returns a new MultiLineHandler.
func (*SingleLineParser) Handle ¶ added in v0.9.0
func (p *SingleLineParser) Handle(input *DecodedInput)
Handle puts all new lines into a channel for later processing.
func (*SingleLineParser) Start ¶ added in v0.9.0
func (p *SingleLineParser) Start()
Start starts the parser.
func (*SingleLineParser) Stop ¶ added in v0.9.0
func (p *SingleLineParser) Stop()
Stop stops the parser.