MCPcopy
hub / github.com/kubewall/kubewall / AddEvent

Method AddEvent

backend/event/event.go:36–55  ·  view source on GitHub ↗

AddEvent adds a count to the event counter.

(key string, f func())

Source from the content-addressed store, hash-verified

34
35// AddEvent adds a count to the event counter.
36func (ec *EventProcessor) AddEvent(key string, f func()) {
37 ec.mu.Lock()
38 defer ec.mu.Unlock()
39
40 if elem, exists := ec.events[key]; exists {
41 ec.order.Remove(elem)
42 delete(ec.events, key)
43 }
44 if len(ec.events) >= ec.maxEvents {
45 oldest := ec.order.Front()
46 if oldest != nil {
47 entry := oldest.Value.(*eventEntry)
48 delete(ec.events, entry.key)
49 ec.order.Remove(oldest)
50 }
51 }
52 entry := &eventEntry{key: key, fn: f}
53 elem := ec.order.PushBack(entry)
54 ec.events[key] = elem
55}
56
57func (ec *EventProcessor) Run() {
58 defer ec.ticker.Stop()

Callers 7

ResourceEventHandlerFunction · 0.80
WaitForSyncMethod · 0.80
GetMethod · 0.80

Calls

no outgoing calls