Documentation ¶
Index ¶
- type EventQueue
- func (eq *EventQueue) Add(id string, obj interface{})
- func (eq *EventQueue) ContainedIDs() util.StringSet
- func (eq *EventQueue) Delete(id string)
- func (eq *EventQueue) Get(id string) (item interface{}, exists bool)
- func (eq *EventQueue) List() []interface{}
- func (eq *EventQueue) Pop() (watch.EventType, interface{})
- func (eq *EventQueue) Replace(idToObjs map[string]interface{})
- func (eq *EventQueue) Update(id string, obj interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventQueue ¶
type EventQueue struct {
// contains filtered or unexported fields
}
EventQueue is a Store implementation that provides a sequence of compressed events to a consumer along with event types. This differs from the FIFO implementation in that FIFO does not provide events when an object is deleted and does not provide the type of event. Events are compressed in a manner similar to FIFO, but accounting for event types and deletions. The exact compression semantics are as follows:
- If a watch.Added is enqueued with state X and a watch.Modified with state Y is received, these are compressed into (Added, Y)
- If a watch.Added is enqueued with state X and a watch.Deleted is received, these are compressed and the item is removed from the queue
- If a watch.Modified is enqueued with state X and a watch.Modified with state Y is received, these two events are compressed into (Modified, Y)
- If a watch.Modified is enqueued with state X and a watch.Deleted is received, these are compressed into (Deleted, X)
It should be noted that the scenario where an object is deleted and re-added is not handled by this type nor is it in scope; the reflector uses UIDs for the IDs passed to stores, so you will never see a delete and a re-add for the same ID.
This type maintains a backing store in order to provide the deleted state on watch.Deleted events. This is necessary because the Store API does not receive the deleted state on a watch.Deleted event (though this state is delivered by the watch API itself, it is not passed on to the reflector Store).
func NewEventQueue ¶
func NewEventQueue() *EventQueue
NewEventQueue returns a new EventQueue ready for action.
func (*EventQueue) Add ¶
func (eq *EventQueue) Add(id string, obj interface{})
Add enqueues a watch.Added event for the given id and state.
func (*EventQueue) ContainedIDs ¶
func (eq *EventQueue) ContainedIDs() util.StringSet
ContainedIDs returns a util.StringSet containing all IDs of the enqueued items. This is a snapshot of a moment in time, and one should keep in mind that other go routines can add or remove items after you call this.
func (*EventQueue) Delete ¶
func (eq *EventQueue) Delete(id string)
Delete enqueues a watch.Delete event for the given id.
func (*EventQueue) Get ¶
func (eq *EventQueue) Get(id string) (item interface{}, exists bool)
Get returns the requested item, or sets exists=false.
func (*EventQueue) List ¶
func (eq *EventQueue) List() []interface{}
List returns a list of all enqueued items.
func (*EventQueue) Pop ¶
func (eq *EventQueue) Pop() (watch.EventType, interface{})
Pop gets the event and object at the head of the queue. If the event is a delete event, Pop deletes the id from the underlying cache.
func (*EventQueue) Replace ¶
func (eq *EventQueue) Replace(idToObjs map[string]interface{})
Replace initializes 'eq' with the state contained in the given map and populates the queue with a watch.Modified event for each of the replaced objects. The backing store takes ownership of idToObjs; you should not reference the map again after calling this function.
func (*EventQueue) Update ¶
func (eq *EventQueue) Update(id string, obj interface{})
Update enqueues a watch.Modified event for the given id and state.