Пример #1
0
func newContainerStore(ref info.ContainerReference, maxAge time.Duration) *containerStorage {
	return &containerStorage{
		ref:         ref,
		recentStats: utils.NewTimedStore(maxAge),
		maxAge:      maxAge,
	}
}
Пример #2
0
// helper function to update the event manager's eventStore
func (self *events) updateEventStore(e *info.Event) {
	self.eventsLock.Lock()
	defer self.eventsLock.Unlock()
	if _, ok := self.eventStore[e.EventType]; !ok {
		maxAge := self.storagePolicy.DefaultMaxAge
		maxNumEvents := self.storagePolicy.DefaultMaxNumEvents
		if age, ok := self.storagePolicy.PerTypeMaxAge[e.EventType]; ok {
			maxAge = age
		}
		if numEvents, ok := self.storagePolicy.PerTypeMaxNumEvents[e.EventType]; ok {
			maxNumEvents = numEvents
		}

		self.eventStore[e.EventType] = utils.NewTimedStore(maxAge, maxNumEvents)
	}
	self.eventStore[e.EventType].Add(e.Timestamp, e)
}