events

package
v0.0.0-...-c130b31 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func IsEnabled

func IsEnabled(event string) bool

func MapCopy

func MapCopy(dst, src interface{})

func NewEventManager

func NewEventManager(storagePolicy StoragePolicy) *events

returns a pointer to an initialized Events object.

func NewWrap

func NewWrap(c EventsConfigMap) error

Types

type Addons

type Addons struct {
	M map[string]string
	// contains filtered or unexported fields
}

func NewAddons

func NewAddons(b map[string]string, m map[string]string) *Addons

func (*Addons) Close

func (self *Addons) Close()

func (*Addons) OnboardFunc

func (self *Addons) OnboardFunc(evt *Event) error

func (*Addons) Watch

func (self *Addons) Watch(eventsChannel *EventChannel) error

Watches for new vms, or vms destroyed.

type AfterFunc

type AfterFunc func(evt *Event) error

AfterFunc represents a after alert function, that can be registered with NewUser function.

type AfterFuncs

type AfterFuncs []AfterFunc

type AfterFuncsMap

type AfterFuncsMap map[alerts.EventAction]AfterFuncs

type Bill

type Bill struct {
	M map[string]string
	// contains filtered or unexported fields
}

func NewBill

func NewBill(b map[string]string, m map[string]string) *Bill

func (*Bill) Close

func (self *Bill) Close()

func (*Bill) OnboardFunc

func (self *Bill) OnboardFunc(evt *Event) error

func (*Bill) Watch

func (self *Bill) Watch(eventsChannel *EventChannel) error

Watches for new vms, or vms destroyed.

type Container

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

func (*Container) Close

func (self *Container) Close()

func (*Container) Watch

func (self *Container) Watch(eventsChannel *EventChannel) error

Watches for new vms, or vms destroyed.

type Event

type Event struct {
	AccountsId string
	// the time at which the event occurred
	Timestamp time.Time

	// the type of event. EventType is an enumerated type
	EventType EventType

	//the action can be
	//bill create, bill delete
	EventAction alerts.EventAction

	// the original event object and all of its extraneous data, ex. an
	// OomInstance
	EventData alerts.EventData
}

Event contains information general to events such as the time at which they occurred, their specific type, and the actual event. Event types are differentiated by the EventType field of Event.

func (*Event) String

func (e *Event) String() string

type EventChannel

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

func NewEventChannel

func NewEventChannel(watchId int) *EventChannel

func (*EventChannel) GetChannel

func (self *EventChannel) GetChannel() chan *Event

func (*EventChannel) GetWatchId

func (self *EventChannel) GetWatchId() int

type EventManager

type EventManager interface {
	// WatchEvents() allows a caller to register for receiving events based on the specified request.
	// On successful registration, an EventChannel object is returned.
	WatchEvents(request *Request) (*EventChannel, error)
	// GetEvents() returns all detected events based on the filters specified in request.
	GetEvents(request *Request) ([]*Event, error)
	// AddEvent allows the caller to add an event to an EventManager
	// object
	AddEvent(e *Event) error
	// Cancels a previously requested watch event.
	StopWatch(watch_id int)
}

EventManager is implemented by Events. It provides two ways to monitor events and one way to add events

type EventType

type EventType string

EventType is an enumerated type which lists the categories under which events may fall. The Event field EventType is populated by this enum.

type EventsConfigMap

type EventsConfigMap map[string]map[string]string

func (EventsConfigMap) Get

func (ec EventsConfigMap) Get(key string) map[string]string

type EventsWriter

type EventsWriter struct {
	H *events
}
var W *EventsWriter

func (*EventsWriter) Close

func (ew *EventsWriter) Close()

func (*EventsWriter) CloseEventChannel

func (ew *EventsWriter) CloseEventChannel(watch_id int)

func (*EventsWriter) GetPastEvents

func (ew *EventsWriter) GetPastEvents(request *Request) ([]*Event, error)

can be called by the api which will return all events satisfying the request

func (*EventsWriter) WatchForEvents

func (ew *EventsWriter) WatchForEvents(request *Request) (*EventChannel, error)

can be called by the api which will take events returned on the channel

func (*EventsWriter) Write

func (ew *EventsWriter) Write(e *Event) error

can be called by the api which will take events returned on the channel

type Machine

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

func (*Machine) Close

func (self *Machine) Close()

func (*Machine) Watch

func (self *Machine) Watch(eventsChannel *EventChannel) error

Watches for new vms, or vms destroyed.

type MultiEvent

type MultiEvent struct {
	Events []*Event
}

func NewMulti

func NewMulti(ea []*Event) *MultiEvent

func (*MultiEvent) IsEnabled

func (me *MultiEvent) IsEnabled() bool

func (*MultiEvent) String

func (e *MultiEvent) String() string

func (*MultiEvent) Write

func (me *MultiEvent) Write() error

type Request

type Request struct {
	// events falling before StartTime do not satisfy the request. StartTime
	// must be left blank in calls to WatchEvents
	StartTime time.Time
	// events falling after EndTime do not satisfy the request. EndTime
	// must be left blank in calls to WatchEvents
	EndTime time.Time
	// EventType is a map that specifies the type(s) of events wanted
	EventType map[EventType]bool
	// contains filtered or unexported fields
}

Request holds a set of parameters by which Event objects may be screened. The caller may want events that occurred within a specific timeframe or of a certain type, which may be specified in the *Request object they pass to an EventManager function

func NewRequest

func NewRequest(opts *eventReqOpts) *Request

returns a pointer to an initialized Request object

type StoragePolicy

type StoragePolicy struct {
	// Defaults limites, used if a per-event limit is not set.
	DefaultMaxAge       time.Duration
	DefaultMaxNumEvents int

	// Per-event type limits.
	PerTypeMaxAge       map[EventType]time.Duration
	PerTypeMaxNumEvents map[EventType]int
}

Policy specifying how many events to store. MaxAge is the max duration for which to keep events. MaxNumEvents is the max number of events to keep (-1 for no limit).

func DefaultStoragePolicy

func DefaultStoragePolicy() StoragePolicy

type StoredEvent

type StoredEvent struct {
	Id         string          `json:"id"`
	AccountsId string          `json:"AccountsId"`
	Type       string          `json:"type"`
	Action     string          `json:"action"`
	Inputs     pairs.JsonPairs `json:"inputs"`
	CreatedAt  string          `json:"created_at"`
}

func NewParseEvent

func NewParseEvent(b []byte) (*StoredEvent, error)

func (*StoredEvent) AsEvent

func (st *StoredEvent) AsEvent() (*Event, error)

type User

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

func NewUser

func NewUser(e EventsConfigMap, fnmap AfterFuncsMap) *User

func (*User) Close

func (self *User) Close()

func (*User) Watch

func (self *User) Watch(eventsChannel *EventChannel) error

Watches for new vms, or vms destroyed.

type Watcher

type Watcher interface {
	Watch(eventChannel *EventChannel) error
}

Interface for event operation handlers.

Directories

Path Synopsis
** Copyright [2013-2017] [Megam Systems] ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License.
** Copyright [2013-2017] [Megam Systems] ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License.

Jump to

Keyboard shortcuts

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