events

package
v0.20.5 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEventManager

func NewEventManager(storagePolicy StoragePolicy) *events

returns a pointer to an initialized Events object.

Types

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 *info.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) ([]*info.Event, error)
	// AddEvent allows the caller to add an event to an EventManager
	// object
	AddEvent(e *info.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 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[info.EventType]bool
	// allows the caller to put a limit on how many
	// events to receive. If there are more events than MaxEventsReturned
	// then the most chronologically recent events in the time period
	// specified are returned. Must be >= 1
	MaxEventsReturned int
	// the absolute container name for which the event occurred
	ContainerName string
	// if IncludeSubcontainers is false, only events occurring in the specific
	// container, and not the subcontainers, will be returned
	IncludeSubcontainers bool
}

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() *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[info.EventType]time.Duration
	PerTypeMaxNumEvents map[info.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

Jump to

Keyboard shortcuts

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