MCPcopy
hub / github.com/kubernetes/client-go / DeltaFIFO

Struct DeltaFIFO

tools/cache/delta_fifo.go:96–127  ·  view source on GitHub ↗

DeltaFIFO is like FIFO, but allows you to process deletes. DeltaFIFO is a producer-consumer queue, where a Reflector is intended to be the producer, and the consumer is whatever calls the Pop() method. DeltaFIFO solves this use case: * You want to process every object change (delta) at most once.

Source from the content-addressed store, hash-verified

94// object will be included in the DeleteFinalStateUnknown markers. These objects
95// could be stale.
96type DeltaFIFO struct {
97 // lock/cond protects access to 'items' and 'queue'.
98 lock sync.RWMutex
99 cond sync.Cond
100
101 // We depend on the property that items in the set are in
102 // the queue and vice versa, and that all Deltas in this
103 // map have at least one Delta.
104 items map[string]Deltas
105 queue []string
106
107 // populated is true if the first batch of items inserted by Replace() has been populated
108 // or Delete/Add/Update was called first.
109 populated bool
110 // initialPopulationCount is the number of items inserted by the first call of Replace()
111 initialPopulationCount int
112
113 // keyFunc is used to make the key used for queued item
114 // insertion and retrieval, and should be deterministic.
115 keyFunc KeyFunc
116
117 // knownObjects list keys that are "known", for the
118 // purpose of figuring out which items have been deleted
119 // when Replace() or Delete() is called.
120 knownObjects KeyListerGetter
121
122 // Indication the queue is closed.
123 // Used to indicate a queue is closed so a control loop can exit when a queue is empty.
124 // Currently, not used to gate any of CRED operations.
125 closed bool
126 closedLock sync.Mutex
127}
128
129var (
130 _ = Queue(&DeltaFIFO{}) // DeltaFIFO is a Queue

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected