model

package
v0.1.48 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MinTimestamp contains the minimum nanoseconds value
	MinTimestamp = int64(-6795364578871345152)
	MaxTimestamp = math.MaxInt64
)

Variables

This section is empty.

Functions

func GetEarliest

func GetEarliest(ev1, ev2 LogEvent) bool

GetEarliest returns whether ev1 has lowest timestamp rather than ev2

Types

type FormatParser

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

FormatParser struct provides simple LogEvent's formatting functionality. The FormatParser could be used for formatting log-events in lql.

func NewFormatParser

func NewFormatParser(fstr string) (*FormatParser, error)

NewFormatParser returns FormatParser for the format string provided or returns an error if any.

The following conventions is applied for the format string fstr: Special constructions like LogEvent's field names, tags and time-stamp format should be placed into curly braces '{', '}': {msg.<json()> - LogEvent message (raw or json escaped) {ts} - LogEvent timestamp in RFC3339 format {vars} - All known tags and fields associated with the LogEvent source {ts.<format(<ts fmt>)>} - LogEvent timestamp in the format provided {vars:<tag or field name>} - Value of the tag or filed name provided

Example:

"app:{vars:name}\t{ts.format(15:04:05.000)}: {msg}" - will print app name associated with the tag "name",
											then timestamp and the log message
"{msg.json()}"      - will print the log message body only (json escaped)
"{vars} - {msg}"    - will print all tags and fields associated with the source and the message body

func (*FormatParser) FormatStr

func (fp *FormatParser) FormatStr(le *LogEvent, tl string) string

FormatStr formats provided log event and the tag line

type Iterator

type Iterator interface {
	// Next switches to the next event, if any
	Next(ctx context.Context)

	// Get returns current LogEvent, the TagsCond for the event or an error if any. It returns io.EOF when end of the collection is reached
	Get(ctx context.Context) (LogEvent, tag.Line, error)

	// Release allows to free underlying resources if they were used for the iteration.
	// This method doesn't affect the iterator position, so subsequent calls to Next() or Get() will
	// get the same result if the Release was not invoked
	Release()

	// SetBackward allows to change direction to backward (true) or forward (false)
	SetBackward(bool)

	// CurrentPos returns the current iterator position
	CurrentPos() records.IteratorPos
}

Iterator interface provides methods for iterating over a collection of LogEvents

type LogEvent

type LogEvent struct {
	// Timestamp of the message. It is filled by collector and can contain either collection timestamp or the
	// message timestamp
	Timestamp int64

	// Msg - the message iteself. Usually it is a slice of bytes that refer to a temporary buffer
	Msg records.Record

	// Fields contains fields associated with the log event
	Fields field.Fields
}

LogEvent struct is used for storing one log-event record in a partition.

func (*LogEvent) MakeItSafe

func (le *LogEvent) MakeItSafe()

func (*LogEvent) Marshal

func (le *LogEvent) Marshal(buf []byte) (int, error)

Marshal encodes the log event into the buffer provided

func (*LogEvent) Release

func (le *LogEvent) Release()

Release drops references to the buffers if the logEvent has ones

func (*LogEvent) Unmarshal

func (le *LogEvent) Unmarshal(buf []byte, newBuf bool) (int, error)

Unmarshal reads the log event data from the buffer. It returns number of bytes read or an error if any

func (*LogEvent) WritableSize

func (le *LogEvent) WritableSize() int

WritableSize returns the number of bytes required to marshal the LogEvent

func (*LogEvent) WriteTo

func (le *LogEvent) WriteTo(ow *xbinary.ObjectsWriter) (int, error)

WriteTo writes LogEvent le into ow

type LogEventIterator

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

LogEventIterator struct wraps a records.Iterator and provides LogEvent Iterator interface over it.

func (*LogEventIterator) CurrentPos

func (lei *LogEventIterator) CurrentPos() records.IteratorPos

func (*LogEventIterator) Get

Get returns current LogEvent record

func (*LogEventIterator) Next

func (lei *LogEventIterator) Next(ctx context.Context)

Next switches to the next LogEvent record

func (*LogEventIterator) Release

func (lei *LogEventIterator) Release()

func (*LogEventIterator) SetBackward

func (lei *LogEventIterator) SetBackward(bkwd bool)

func (*LogEventIterator) Wrap

Wrap sets the underlying records.Iterator it

type Mixer

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

Mixer allows to mix 2 Iterators to one. Mixer provides the Iterator interface

func (*Mixer) CurrentPos

func (mr *Mixer) CurrentPos() records.IteratorPos

func (*Mixer) Get

func (mr *Mixer) Get(ctx context.Context) (LogEvent, tag.Line, error)

Get is the part of Iterator interface

func (*Mixer) Init

func (mr *Mixer) Init(sf SelectF, it1, it2 Iterator)

Init initializes the mixer

func (*Mixer) Next

func (mr *Mixer) Next(ctx context.Context)

Next is the part of Iterator interface

func (*Mixer) Release

func (mr *Mixer) Release()

func (*Mixer) SetBackward

func (mr *Mixer) SetBackward(bkwd bool)

type SelectF

type SelectF func(ev1, ev2 LogEvent) bool

SelectF decides which one should be selected, it returns true if ev1 must be selected instead of ev2. If ev2 should be used then it returns false

type TestLogEventsWrapper added in v0.1.0

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

func NewTestLogEventsWrapper added in v0.1.0

func NewTestLogEventsWrapper(les []LogEvent) *TestLogEventsWrapper

func (*TestLogEventsWrapper) CurrentPos added in v0.1.0

func (tle *TestLogEventsWrapper) CurrentPos() records.IteratorPos

func (*TestLogEventsWrapper) Get added in v0.1.0

func (*TestLogEventsWrapper) Next added in v0.1.0

func (tle *TestLogEventsWrapper) Next(ctx context.Context)

func (*TestLogEventsWrapper) Release added in v0.1.0

func (tle *TestLogEventsWrapper) Release()

func (*TestLogEventsWrapper) SetBackward added in v0.1.0

func (tle *TestLogEventsWrapper) SetBackward(bkwd bool)

type TimeRange added in v0.1.0

type TimeRange struct {
	// MinTs contains minimum time in the interval value
	MinTs int64
	// MaxTs contains maximum allowed time value in the interval
	MaxTs int64
}

TimeRange struct defines a time interval.

Directories

Path Synopsis
Package tag provides functions for working with tags.
Package tag provides functions for working with tags.

Jump to

Keyboard shortcuts

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