event

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2016 License: MIT Imports: 15 Imported by: 12

Documentation

Index

Constants

View Source
const (
	ENCODING_TYPE_JSON = "json"
	ENCODING_TYPE_BIN  = "bin"
)
View Source
const (
	OK = iota
	WARNING
	CRITICAL
)
View Source
const (
	StateStart uint32 = iota
	StatePipeline
	StatePolicy
	StateIncident
	StateComplete
)
View Source
const (
	KEEP_ALIVE_SERVICE_NAME = "KeepAlive"
)

Variables

View Source
var (
	EVENT_BUCKET_NAME      = []byte("events")
	INCIDENT_BUCKET_NAME   = []byte("incidents")
	MANAGEMENT_BUCKET_NAME = []byte("management")
	INCIDENT_COUNT_NAME    = []byte("incident_count")
	INDEX_FILE_NAME        = "bangarang-index.db"
)

Functions

func DefaultIncidentFormatter added in v0.15.0

func DefaultIncidentFormatter(i *Incident) string

DefaultIncidentFormatter is the legacy formatter for incidents

func Status added in v0.15.0

func Status(code int) string

Types

type BinDecoder added in v0.15.0

type BinDecoder struct {
}

func (*BinDecoder) Decode added in v0.15.0

func (m *BinDecoder) Decode(raw []byte, e *Event) error

type BinEncoder added in v0.15.0

type BinEncoder struct {
}

func (*BinEncoder) Encode added in v0.15.0

func (m *BinEncoder) Encode(e *Event) (buff []byte, err error)

type Decoder

type Decoder interface {
	Decode(raw []byte, ev *Event) error
}

decodes the raw event and sends the decoded event to it's destination

func NewBinDecoder added in v0.15.0

func NewBinDecoder() Decoder

func NewJsonDecoder

func NewJsonDecoder() Decoder

type DecoderFactory

type DecoderFactory func() Decoder

type Encoder

type Encoder interface {
	Encode(e *Event) ([]byte, error)
}

encodes the given event and sends the encoded value on the dst channel

func NewBinEncoder added in v0.15.0

func NewBinEncoder() Encoder

func NewJsonEncoder

func NewJsonEncoder() Encoder

type EncoderDecoder

type EncoderDecoder interface {
	Encoder
	Decoder
}

type EncoderFactory

type EncoderFactory func() Encoder

type EncodingPool

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

func NewEncodingPool

func NewEncodingPool(enc EncoderFactory, dec DecoderFactory, maxSize int) *EncodingPool

func (*EncodingPool) Decode

func (t *EncodingPool) Decode(buff []byte, ev *Event) error

use one of the pooled decoders to decode the given event

func (*EncodingPool) Encode

func (t *EncodingPool) Encode(ev *Event) ([]byte, error)

use one of the pooled encoders to encode the given event

type Event

type Event struct {
	Metric float64   `json:"metric" msg:"metric"`
	Tags   *TagSet   `json:"tags" msg:"tags"`
	Time   time.Time `json:"time" msg: "time"`
	// contains filtered or unexported fields
}

Event represents a metric as it passes through the pipeline. It holds meta data about the metric, as well as methods to trace the event as it is processed

func NewEvent added in v0.15.0

func NewEvent() *Event

func (*Event) Get

func (e *Event) Get(key string) string

Get any value on an event as a string

func (*Event) GetState added in v0.15.0

func (e *Event) GetState() uint32

GetState returns the current state of the event at call time

func (*Event) IndexName

func (e *Event) IndexName() string

func (*Event) MarshalBinary added in v0.15.0

func (e *Event) MarshalBinary() ([]byte, error)

MarshalBinary creates the binary representation of an event Size header 8 bytes Metric 8 bytes Time seconds 8 bytes Time nanoseconds 8 bytes

TagSetSize 1 byte (max 256 key->val pairs)

Tags: key size 1 byte Tags: key (max 256 bytes) Tags: value size 1 byte Tags: value (max 256 bytes) repeat

func (*Event) SetState added in v0.15.0

func (e *Event) SetState(s uint32)

SetState atomically updates the event's state to the given number

func (*Event) UnmarshalBinary added in v0.15.0

func (e *Event) UnmarshalBinary(buff []byte) error

func (*Event) WaitForState added in v0.15.0

func (e *Event) WaitForState(s uint32, timeout time.Duration) func()

WaitForState returns a function that will block until that state has been met or the timeout has been hit

type EventPasser added in v0.15.0

type EventPasser interface {
	PassEvent(e *Event)
}

EventPasser provides a method for passing an event down a step in the pipeline

type Incident

type Incident struct {
	EventName   []byte `json:"event" msg:"event_name"`
	Time        int64  `json:"time" msg:"time"`
	Id          int64  `json:"id" msg:"id"`
	Active      bool   `json:"active" msg:"active"`
	Description string `json:"description" msg:"description"`
	Policy      string `json:"policy" msg:"policy"`
	Status      int    `json:"status" "msg:"status"`

	Event
	// contains filtered or unexported fields
}

An incident is created whenever an event changes to a state

func NewIncident

func NewIncident(policy string, status int, e *Event) *Incident

NewIncident creats and returns a new incident for the given event

func (*Incident) FormatDescription

func (i *Incident) FormatDescription() string

FormatDescription calls the formatter for this incident

func (*Incident) GetEvent

func (i *Incident) GetEvent() *Event

GetEvent returns a pointer to the event housed within the incident

func (*Incident) GetResolve added in v0.15.0

func (i *Incident) GetResolve() chan *Incident

GetResolve return the incidents resover channel

func (*Incident) IndexName

func (i *Incident) IndexName() []byte

IndexName returns the unique name for an incident of this description

func (*Incident) SetResolve added in v0.15.0

func (i *Incident) SetResolve(r chan *Incident)

SetResolve sets the incident resolver channel for the given incident

type IncidentFormatter added in v0.15.0

type IncidentFormatter func(*Incident) string

IncidentFormatter will createa a string representation of an incident

type IncidentPasser added in v0.15.0

type IncidentPasser interface {
	PassIncident(i *Incident)
}

IncidentPasser passes an incdent to the next step in the pipeline

type Index

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

func NewIndex

func NewIndex() *Index

func (*Index) Close

func (i *Index) Close()

close out the index

func (*Index) Delete

func (i *Index) Delete()

delete any psersistants associated with the index

func (*Index) DeleteIncidentById

func (i *Index) DeleteIncidentById(id []byte)

func (*Index) GetIncident

func (i *Index) GetIncident(id []byte) *Incident

get an event from the index

func (*Index) GetIncidentCounter

func (i *Index) GetIncidentCounter() int64

func (*Index) ListIncidents

func (i *Index) ListIncidents() []*Incident

list all the known events

func (*Index) PutIncident

func (i *Index) PutIncident(in *Incident)

write the incident to the db

func (*Index) UpdateIncidentCounter

func (i *Index) UpdateIncidentCounter(count int64)

type JsonDecoder

type JsonDecoder struct {
}

func (*JsonDecoder) Decode

func (j *JsonDecoder) Decode(raw []byte, e *Event) error

type JsonEncoder

type JsonEncoder struct {
}

func (*JsonEncoder) Encode

func (j *JsonEncoder) Encode(e *Event) ([]byte, error)

type KeyVal added in v0.15.0

type KeyVal struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

KeyVal is a key value pair, used in matching to tags on events

type TagSet added in v0.15.0

type TagSet []KeyVal

TagSet is a collection of key/val pairs that will always give the same order of the tags

func NewTagset added in v0.15.0

func NewTagset(size int) *TagSet

func (*TagSet) ForEach added in v0.15.0

func (t *TagSet) ForEach(f func(k, v string))

func (*TagSet) Get added in v0.15.0

func (t *TagSet) Get(key string) string

Get returns the value of a key in linear time. An empty string if it wasn't found

func (*TagSet) Len added in v0.15.0

func (t *TagSet) Len() int

func (*TagSet) MarshalBinary added in v0.15.0

func (t *TagSet) MarshalBinary(buff []byte) error

func (*TagSet) Set added in v0.15.0

func (t *TagSet) Set(key, val string)

func (*TagSet) SortByKey added in v0.15.0

func (t *TagSet) SortByKey()

func (*TagSet) SortByValue added in v0.15.0

func (t *TagSet) SortByValue()

func (*TagSet) String added in v0.15.0

func (t *TagSet) String() string

Jump to

Keyboard shortcuts

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