event

package
v0.0.0-...-bd3593b Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2015 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ENCODING_TYPE_JSON    = "json"
	ENCODING_TYPE_MSGPACK = "msgp"
)
View Source
const (
	OK = iota
	WARNING
	CRITICAL
)
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")
)

Functions

This section is empty.

Types

type DecFunc

type DecFunc func(d Decoder)

type Decoder

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

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

func NewJsonDecoder

func NewJsonDecoder() Decoder

func NewMsgPackDecoder

func NewMsgPackDecoder() Decoder

type DecoderFactory

type DecoderFactory func() Decoder

type EncFunc

type EncFunc func(e Encoder)

type Encoder

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

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

func NewJsonEncoder

func NewJsonEncoder() Encoder

func NewMsgPackEncoder

func NewMsgPackEncoder() 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(d DecFunc)

use one of the pooled decoders to decode the given event

func (*EncodingPool) Encode

func (t *EncodingPool) Encode(e EncFunc)

use one of the pooled encoders to encode the given event

type Event

type Event struct {
	Host       string            `json:"host" msg:"host"`
	Service    string            `json:"service" msg:"service"`
	SubService string            `json:"sub_type" msg:"sub_service"`
	Metric     float64           `json:"metric" msg:"metric"`
	Occurences int               `json:"occurences" msg:"occurences"`
	Tags       map[string]string `json:"tags" msg:"tags"`
	Status     int               `json:"status" msg:"status"`
	IncidentId *int64            `json:"incident,omitempty" msg:"incident_id"`
	// contains filtered or unexported fields
}

func (*Event) DecodeMsg

func (z *Event) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Event) EncodeMsg

func (z *Event) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Event) FormatDescription

func (e *Event) FormatDescription() string

func (*Event) Get

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

Get any value on an event as a string

func (*Event) IndexName

func (e *Event) IndexName() string

func (*Event) MarshalJSON

func (mj *Event) MarshalJSON() ([]byte, error)

func (*Event) MarshalJSONBuf

func (mj *Event) MarshalJSONBuf(buf fflib.EncodingBuffer) error

func (*Event) MarshalMsg

func (z *Event) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Event) Msgsize

func (z *Event) Msgsize() (s int)

func (*Event) UnmarshalJSON

func (uj *Event) UnmarshalJSON(input []byte) error

func (*Event) UnmarshalJSONFFLexer

func (uj *Event) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

func (*Event) UnmarshalMsg

func (z *Event) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

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"`
	Escalation  string `json:"escalation" msg:"escalation"`
	Description string `json:"description" msg:"description"`
	Policy      string `json:"policy" msg:"policy"`
	Event
}

An incident is created whenever an event changes to a state that is not event.OK

func NewIncident

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

func (*Incident) DecodeMsg

func (z *Incident) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Incident) EncodeMsg

func (z *Incident) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Incident) FormatDescription

func (i *Incident) FormatDescription() string

func (*Incident) GetEvent

func (i *Incident) GetEvent() *Event

func (*Incident) IndexName

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

func (*Incident) MarshalJSON

func (mj *Incident) MarshalJSON() ([]byte, error)

func (*Incident) MarshalJSONBuf

func (mj *Incident) MarshalJSONBuf(buf fflib.EncodingBuffer) error

func (*Incident) MarshalMsg

func (z *Incident) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Incident) Msgsize

func (z *Incident) Msgsize() (s int)

func (*Incident) UnmarshalJSON

func (uj *Incident) UnmarshalJSON(input []byte) error

func (*Incident) UnmarshalJSONFFLexer

func (uj *Incident) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

func (*Incident) UnmarshalMsg

func (z *Incident) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Index

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

func NewIndex

func NewIndex(dbName string) *Index

func (*Index) Close

func (i *Index) Close() error

close out the index

func (*Index) Delete

func (i *Index) Delete() error

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) GetKeepAlives

func (i *Index) GetKeepAlives() []*Event

return all keep alive's as events

func (*Index) ListIncidents

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

list all the known events

func (*Index) PutEvent

func (i *Index) PutEvent(e *Event)

insert the event into the index

func (*Index) PutIncident

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

write the incident to the db

func (*Index) UpdateEvent

func (i *Index) UpdateEvent(e *Event)

updates the event, will not apply any of the dedupe logic

func (*Index) UpdateIncidentCounter

func (i *Index) UpdateIncidentCounter(count int64)

type JsonDecoder

type JsonDecoder struct {
}

func (*JsonDecoder) Decode

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

type JsonEncoder

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

func (*JsonEncoder) Encode

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

type MsgPackDecoder

type MsgPackDecoder struct {
}

func (*MsgPackDecoder) Decode

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

type MsgPackEncoder

type MsgPackEncoder struct {
}

func (*MsgPackEncoder) Encode

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

Jump to

Keyboard shortcuts

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