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
// 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
maxIntervalInSeconds int
maxIntervalInSeconds uint
// clock is used to allow for testing over a time interval
clock clock.Clock
@ -126,8 +126,8 @@ func NewEventAggregator(lruCacheSize int, keyFunc EventAggregatorKeyFunc, messag
cache: lru.New(lruCacheSize),
keyFunc: keyFunc,
messageFunc: messageFunc,
maxEvents: maxEvents,
maxIntervalInSeconds: maxIntervalInSeconds,
maxEvents: uint(maxEvents),
maxIntervalInSeconds: uint(maxIntervalInSeconds),
clock: clock,
}
}
@ -163,7 +163,7 @@ func (e *EventAggregator) EventAggregate(newEvent *v1.Event) (*v1.Event, error)
record.lastTimestamp = now
e.cache.Add(aggregateKey, record)
if record.localKeys.Len() < e.maxEvents {
if uint(record.localKeys.Len()) < e.maxEvents {
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
type eventLog struct {
// The number of times the event has occurred since first occurrence.
count int
count uint
// The time at which the event was first recorded.
firstTimestamp metav1.Time
@ -251,7 +251,7 @@ func (e *eventLogger) eventObserve(newEvent *v1.Event) (*v1.Event, []byte, error
e.cache.Add(
key,
eventLog{
count: int(event.Count),
count: uint(event.Count),
firstTimestamp: event.FirstTimestamp,
name: event.Name,
resourceVersion: event.ResourceVersion,
@ -269,7 +269,7 @@ func (e *eventLogger) updateState(event *v1.Event) {
e.cache.Add(
key,
eventLog{
count: int(event.Count),
count: uint(event.Count),
firstTimestamp: event.FirstTimestamp,
name: event.Name,
resourceVersion: event.ResourceVersion,