T - a type of Kubernetes resourcepublic interface EventCache<T extends HasMetadata>
Events representing Kubernetes resources.
Instances of implementations of this interface must be
safe for concurrent usage by multiple Threads.
Event,
EventQueueCollection| Modifier and Type | Method and Description |
|---|---|
Event<T> |
add(Object source,
AbstractEvent.Type eventType,
T resource)
Adds a new
Event constructed out of the parameters
supplied to this method to this EventCache implementation
and returns the Event that was added. |
void |
replace(Collection<? extends T> incomingResources,
Object resourceVersion)
A "full replace" operation that atomically replaces all internal
state with new state derived from the supplied
Collection
of resources. |
void |
synchronize()
Synchronizes this
EventCache implementation's state with
its downstream consumers, if any. |
Event<T> add(Object source, AbstractEvent.Type eventType, T resource)
Event constructed out of the parameters
supplied to this method to this EventCache implementation
and returns the Event that was added.
Implementations of this method may return null to
indicate that for whatever reason no Event was actually
added.
source - the source of the
Event that will be created and added; must not be nulleventType - the type of Event that will be created and added; must not be nullresource - the resource of
the Event that will be created and added must not be
nullEvent that was created and added, or null if no Event was actually added as a result of this
method's invocationNullPointerException - if any of the parameters is
nullEventvoid replace(Collection<? extends T> incomingResources, Object resourceVersion)
Collection
of resources.incomingResources - the resources comprising the new state;
must not be null; must be synchronized
on when accessingresourceVersion - the notional version of the supplied
Collection; may be null; often ignored by
implementationsNullPointerException - if incomingResources is
nullvoid synchronize()
EventCache implementation's state with
its downstream consumers, if any.
Not all EventCache implementations need support
synchronization. An implementation of this method that does
nothing is explicitly permitted.
Implementations of this method must expect to be called on a fixed schedule.
This method emulates the Resync function in the Go code's DeltaFifo construct
Specifically, it is anticipated that an implementation of this
method that does not simply return will go through the internal
resources that this EventCache knows about, and, for each
that does not have an event queue set up for it
already—i.e. for each that is not currently being
processed— will fire a SynchronizationEvent. This
will have the effect of "heartbeating" the current desired state
of the system "downstream" to processors that may wish to alter
the actual state of the system to conform to it.
SynchronizationEventCopyright © 2017–2021, microBean™. All rights reserved.