type byTimestamp … // functions necessary to implement the sort interface on the Events struct func (e byTimestamp) Len() int { … } func (e byTimestamp) Swap(i, j int) { … } func (e byTimestamp) Less(i, j int) bool { … } type EventChannel … type Request … type EventManager … type events … type watch … func NewEventChannel(watchID int) *EventChannel { … } type StoragePolicy … func DefaultStoragePolicy() StoragePolicy { … } // returns a pointer to an initialized Events object. func NewEventManager(storagePolicy StoragePolicy) EventManager { … } // returns a pointer to an initialized Request object func NewRequest() *Request { … } // returns a pointer to an initialized watch object func newWatch(request *Request, eventChannel *EventChannel) *watch { … } func (ch *EventChannel) GetChannel() chan *info.Event { … } func (ch *EventChannel) GetWatchId() int { … } // sorts and returns up to the last MaxEventsReturned chronological elements func getMaxEventsReturned(request *Request, eSlice []*info.Event) []*info.Event { … } // If the request wants all subcontainers, this returns if the request's // container path is a prefix of the event container path. Otherwise, // it checks that the container paths of the event and request are // equivalent func isSubcontainer(request *Request, event *info.Event) bool { … } // determines if an event occurs within the time set in the request object and is the right type func checkIfEventSatisfiesRequest(request *Request, event *info.Event) bool { … } // method of Events object that screens Event objects found in the eventStore // attribute and if they fit the parameters passed by the Request object, // adds it to a slice of *Event objects that is returned. If both MaxEventsReturned // and StartTime/EndTime are specified in the request object, then only // up to the most recent MaxEventsReturned events in that time range are returned. func (e *events) GetEvents(request *Request) ([]*info.Event, error) { … } // method of Events object that maintains an *Event channel passed by the user. // When an event is added by AddEvents that satisfies the parameters in the passed // Request object it is fed to the channel. The StartTime and EndTime of the watch // request should be uninitialized because the purpose is to watch indefinitely // for events that will happen in the future func (e *events) WatchEvents(request *Request) (*EventChannel, error) { … } // helper function to update the event manager's eventStore func (e *events) updateEventStore(event *info.Event) { … } func (e *events) findValidWatchers(event *info.Event) []*watch { … } // method of Events object that adds the argument Event object to the // eventStore. It also feeds the event to a set of watch channels // held by the manager if it satisfies the request keys of the channels func (e *events) AddEvent(event *info.Event) error { … } // Removes a watch instance from the EventManager's watchers map func (e *events) StopWatch(watchID int) { … }