change event count type

event count type had better to be uint.
pull/6/head
xu fei 2017-04-12 09:53:39 +08:00 committed by GitHub
parent ebf1439d93
commit 461761e5b0
1 changed files with 8 additions and 8 deletions

View File

@ -110,10 +110,10 @@ type EventAggregator struct {
messageFunc EventAggregatorMessageFunc messageFunc EventAggregatorMessageFunc
// The maximum number of events in the specified interval before aggregation occurs // The maximum number of events in the specified interval before aggregation occurs
maxEvents int maxEvents uint
// The amount of time in seconds that must transpire since the last occurrence of a similar event before it's considered new // The amount of time in seconds that must transpire since the last occurrence of a similar event before it's considered new
maxIntervalInSeconds int maxIntervalInSeconds uint
// clock is used to allow for testing over a time interval // clock is used to allow for testing over a time interval
clock clock.Clock clock clock.Clock
@ -126,8 +126,8 @@ func NewEventAggregator(lruCacheSize int, keyFunc EventAggregatorKeyFunc, messag
cache: lru.New(lruCacheSize), cache: lru.New(lruCacheSize),
keyFunc: keyFunc, keyFunc: keyFunc,
messageFunc: messageFunc, messageFunc: messageFunc,
maxEvents: maxEvents, maxEvents: uint(maxEvents),
maxIntervalInSeconds: maxIntervalInSeconds, maxIntervalInSeconds: uint(maxIntervalInSeconds),
clock: clock, clock: clock,
} }
} }
@ -163,7 +163,7 @@ func (e *EventAggregator) EventAggregate(newEvent *v1.Event) (*v1.Event, error)
record.lastTimestamp = now record.lastTimestamp = now
e.cache.Add(aggregateKey, record) e.cache.Add(aggregateKey, record)
if record.localKeys.Len() < e.maxEvents { if uint(record.localKeys.Len()) < e.maxEvents {
return newEvent, nil return newEvent, nil
} }
@ -191,7 +191,7 @@ func (e *EventAggregator) EventAggregate(newEvent *v1.Event) (*v1.Event, error)
// eventLog records data about when an event was observed // eventLog records data about when an event was observed
type eventLog struct { type eventLog struct {
// The number of times the event has occurred since first occurrence. // The number of times the event has occurred since first occurrence.
count int count uint
// The time at which the event was first recorded. // The time at which the event was first recorded.
firstTimestamp metav1.Time firstTimestamp metav1.Time
@ -251,7 +251,7 @@ func (e *eventLogger) eventObserve(newEvent *v1.Event) (*v1.Event, []byte, error
e.cache.Add( e.cache.Add(
key, key,
eventLog{ eventLog{
count: int(event.Count), count: uint(event.Count),
firstTimestamp: event.FirstTimestamp, firstTimestamp: event.FirstTimestamp,
name: event.Name, name: event.Name,
resourceVersion: event.ResourceVersion, resourceVersion: event.ResourceVersion,
@ -269,7 +269,7 @@ func (e *eventLogger) updateState(event *v1.Event) {
e.cache.Add( e.cache.Add(
key, key,
eventLog{ eventLog{
count: int(event.Count), count: uint(event.Count),
firstTimestamp: event.FirstTimestamp, firstTimestamp: event.FirstTimestamp,
name: event.Name, name: event.Name,
resourceVersion: event.ResourceVersion, resourceVersion: event.ResourceVersion,