match

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoTerms       = errors.New("no terms")
	ErrTooManyTerms  = errors.New("too many terms")
	ErrAnchorRange   = errors.New("anchor out of range")
	ErrAnchorNoDupes = errors.New("non zero anchors unsupported with duplicate terms")
)
View Source
var (
	ErrTermType    = errors.New("unknown term type")
	ErrTermEmpty   = errors.New("empty term")
	ErrTermCompile = errors.New("term compile error")
)

Functions

func IsRegex

func IsRegex(v string) bool

Types

type Hits

type Hits struct {
	Cnt   int
	Logs  []LogEntry
	Props map[PropKey]any
}

func (Hits) Index

func (h Hits) Index(i int) []LogEntry

func (Hits) IndexProps added in v0.0.14

func (h Hits) IndexProps(i int) map[string]any

func (Hits) Last

func (h Hits) Last() []LogEntry

func (*Hits) PopFront

func (h *Hits) PopFront() []LogEntry

type InverseSeq

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

func NewInverseSeq

func NewInverseSeq(window int64, seqTerms []TermT, resetTerms []ResetT) (*InverseSeq, error)

func (*InverseSeq) Eval

func (r *InverseSeq) Eval(clock int64) (hits Hits)

func (*InverseSeq) GarbageCollect

func (r *InverseSeq) GarbageCollect(clock int64)

Remove all terms that are older than the window.

func (*InverseSeq) Scan

func (r *InverseSeq) Scan(e entry.LogEntry) (hits Hits)

type InverseSet

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

func NewInverseSet

func NewInverseSet(window int64, setTerms []TermT, resetTerms []ResetT) (*InverseSet, error)

func (*InverseSet) Eval

func (r *InverseSet) Eval(clock int64) (hits Hits)

Assert clock, may used to close out matcher

func (*InverseSet) GarbageCollect

func (r *InverseSet) GarbageCollect(clock int64)

Remove all terms that are older than the window.

func (*InverseSet) Scan

func (r *InverseSet) Scan(e entry.LogEntry) (hits Hits)

type LogEntry

type LogEntry = entry.LogEntry

type MatchFunc

type MatchFunc func(string) bool

func NewJqJson

func NewJqJson(term string) (MatchFunc, error)

type MatchSeq

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

func NewMatchSeq

func NewMatchSeq(window int64, seqTerms ...TermT) (*MatchSeq, error)

func (*MatchSeq) Eval

func (r *MatchSeq) Eval(clock int64) (h Hits)

Because match sequence is edge triggered, there won't be hits.

func (*MatchSeq) GarbageCollect

func (r *MatchSeq) GarbageCollect(clock int64)

Remove all terms that are older than the window.

func (*MatchSeq) Scan

func (r *MatchSeq) Scan(e LogEntry) (hits Hits)

type MatchSet

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

func NewMatchSet

func NewMatchSet(window int64, setTerms ...TermT) (*MatchSet, error)

func (*MatchSet) Eval

func (r *MatchSet) Eval(clock int64) (h Hits)

Because match sequence is edge triggered, there won't be hits. But can GC.

func (*MatchSet) GarbageCollect

func (r *MatchSet) GarbageCollect(clock int64)

Remove all terms that are older than the window.

func (*MatchSet) Scan

func (r *MatchSet) Scan(e LogEntry) (hits Hits)

type MatchSingle

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

func NewMatchSingle

func NewMatchSingle(term TermT) (*MatchSingle, error)

func (*MatchSingle) Eval

func (r *MatchSingle) Eval(clock int64) (hits Hits)

func (*MatchSingle) GarbageCollect

func (r *MatchSingle) GarbageCollect(clock int64)

func (*MatchSingle) Scan

func (r *MatchSingle) Scan(e entry.LogEntry) (hits Hits)

type Matcher

type Matcher interface {
	Eval(int64) Hits
	Scan(e entry.LogEntry) Hits
	GarbageCollect(int64)
}

type PropKey added in v0.0.14

type PropKey struct {
	Idx int
	Key string
}

type ResetT

type ResetT struct {
	Term     TermT // Inverse term
	Window   int64 // Window size; defaults to 0 which in combination with !Absolute means the window is the range of the matched sequence.
	Slide    int64 // Slide the anchor, +/- relative to the anchor term
	Anchor   uint8 // Anchor term; defaults to first event in match sequence
	Absolute bool  // Absolute window time or relative to the range of the matched sequence.
}

type TermT

type TermT struct {
	Type  TermTypeT
	Value string
}

func (TermT) NewMatcher

func (tt TermT) NewMatcher() (m MatchFunc, err error)

type TermTypeT

type TermTypeT int
const (
	TermRaw TermTypeT = iota
	TermRegex
	TermJqJson
	TermJqYaml
)

func (TermTypeT) String

func (t TermTypeT) String() string

Jump to

Keyboard shortcuts

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