daemon

package
v0.0.0-...-4976903 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStopped = errors.New("daemon: stopped")

Functions

This section is empty.

Types

type Daemon

type Daemon struct {
	Listener  net.Listener
	Logger    log.Printer
	Groups    map[string][]Rule
	Cache     MessageCache
	Store     MessageStore
	SampleSrc rand.Source
	SamplePct float64
	// contains filtered or unexported fields
}

func (*Daemon) Serve

func (d *Daemon) Serve() error

func (*Daemon) Stop

func (d *Daemon) Stop(ctx context.Context) error

type EvalRecord

type EvalRecord struct {
	Message *Message
	// contains filtered or unexported fields
}

func (*EvalRecord) EndTime

func (rec *EvalRecord) EndTime() time.Time

func (*EvalRecord) Group

func (rec *EvalRecord) Group() string

func (*EvalRecord) Rule

func (rec *EvalRecord) Rule(i int) *RuleEvalRecord

func (*EvalRecord) RuleLen

func (rec *EvalRecord) RuleLen() int

func (*EvalRecord) StartTime

func (rec *EvalRecord) StartTime() time.Time

type Message

type Message struct {
	Envelope *enmime.Envelope
	// contains filtered or unexported fields
}

func (*Message) FullText

func (m *Message) FullText() []byte

func (*Message) IsSampled

func (m *Message) IsSampled() bool

type MessageCache

type MessageCache interface {
	Get(cacheKey string) *Message
	Put(cacheKey string, msg *Message, size uint64)
}

type MessageStore

type MessageStore interface {
	GetMetadata(storeID string) (Metadata, bool, error)
	PutMessage(storeID string, msg *Message) error
	RecordEval(storeID string, r *EvalRecord) error
}

type Metadata

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

func NewMetadata

func NewMetadata(sampled bool, tags map[string]string) Metadata

type Rule

type Rule interface {
	fmt.Stringer
	Eval(ctx context.Context, logger log.Printer, msg *Message, tagger Tagger) (match bool, err error)
}

type RuleEvalRecord

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

func (*RuleEvalRecord) DeleteTag

func (rec *RuleEvalRecord) DeleteTag(key string)

func (*RuleEvalRecord) EndTime

func (rec *RuleEvalRecord) EndTime() time.Time

func (*RuleEvalRecord) Err

func (rec *RuleEvalRecord) Err() error

func (*RuleEvalRecord) GetTag

func (rec *RuleEvalRecord) GetTag(key string) (value string, hit bool)

func (*RuleEvalRecord) Keys

func (rec *RuleEvalRecord) Keys() []string

func (*RuleEvalRecord) Match

func (rec *RuleEvalRecord) Match() bool

func (*RuleEvalRecord) Rule

func (rec *RuleEvalRecord) Rule() string

func (*RuleEvalRecord) SetTag

func (rec *RuleEvalRecord) SetTag(key, value string)

func (*RuleEvalRecord) StartTime

func (rec *RuleEvalRecord) StartTime() time.Time

func (*RuleEvalRecord) TagChange

func (rec *RuleEvalRecord) TagChange(i int) TagChange

func (*RuleEvalRecord) TagChangeLen

func (rec *RuleEvalRecord) TagChangeLen() int

type TagChange

type TagChange struct {
	Time  time.Time
	Key   string
	Value *string
}

type Tagger

type Tagger interface {
	Keys() []string
	GetTag(key string) (value string, hit bool)
	SetTag(key, value string)
	DeleteTag(key string)
}

Jump to

Keyboard shortcuts

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