heartbeat

package
v0.0.0-...-d841f61 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeartbeatSourceDefault = ""
	HeartbeatSourceMongo   = "mongo"
)

Variables

This section is empty.

Functions

func BuildID

func BuildID(mapping map[string]string) string

Types

type Adapter

type Adapter interface {
	Get() ([]Heartbeat, error)
}

func NewAdapter

func NewAdapter(dbClient mongo.DbClient) Adapter

type Heartbeat

type Heartbeat struct {
	Pattern          map[string]string `bson:"pattern"`
	ExpectedInterval string            `bson:"expected_interval"`
	Output           string            `bson:"output"`
}

func (*Heartbeat) ToHeartBeatItem

func (h *Heartbeat) ToHeartBeatItem() (Item, error)

type Item

type Item struct {
	Mappings    map[string]string `toml:"mappings"`
	MaxDuration time.Duration     `toml:"maxduration"`
	Source      string
	Output      string
}

Item contains the required informations for the HeartBeat engine to work.

func NewItem

func NewItem(maxDuration time.Duration) Item

NewItem creates a HeartBeatItem instance for you.

func (*Item) AddMapping

func (li *Item) AddMapping(field, matches string) error

AddMapping simplifies your life to declare a useful HeartBeatItem. You can safely ignore the error, it only says that the mapping you try to insert already exists.

func (*Item) ID

func (li *Item) ID() string

type SafeHeartbeatItems

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

func NewSafeHeartbeatItems

func NewSafeHeartbeatItems() SafeHeartbeatItems

func (*SafeHeartbeatItems) AddItem

func (i *SafeHeartbeatItems) AddItem(hi Item)

func (*SafeHeartbeatItems) Clear

func (i *SafeHeartbeatItems) Clear()

func (*SafeHeartbeatItems) Len

func (i *SafeHeartbeatItems) Len() int

func (*SafeHeartbeatItems) Value

func (i *SafeHeartbeatItems) Value() []Item

Jump to

Keyboard shortcuts

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