pub struct Reflector<P: Processor> { /* private fields */ }Expand description
Reflector composes a source of data with a processor that’s used to transform the data, and then stores the
results and allows for shared access by multiple callers.
Reflectors are a term often found in the context of custom Kubernetes controllers, where they’re used to reduce the
load on the Kubernetes API server by caching the state of resources in memory. Reflector provides comparable
functionality, allowing for a single data source to be consumed, and then shared amongst multiple callers. However,
Reflector utilizes the concept of a processor, which dictates both the type of data that can be consumed and
data that gets stored. This means that Reflector is more than just a cache of the data source, but also
potentially a mapped version of it, allowing for transforming the data in whatever way is necessary.
Implementations§
Source§impl<P: Processor> Reflector<P>
impl<P: Processor> Reflector<P>
Sourcepub fn new<S, I>(source: S, processor: P) -> (Self, ReflectorWorker<P, S>)
pub fn new<S, I>(source: S, processor: P) -> (Self, ReflectorWorker<P, S>)
Creates a new reflector with the given data source and processor.
A reflector composes a source of data with a processor that’s used to transform the data, and then stores the processed results. It can be listened to for updates, and cheaply shared. This allows multiple interested components to subscribe to the same data source without having to duplicate the processing or storage of the data.
Returns the reflector alongside a ReflectorWorker that consumes the data source and feeds the processed
items into the shared state. The reflector is usable immediately, but reports only the initial state until
the worker is added to a Supervisor and starts running. Register the worker
as transient, for the reasons given on ReflectorWorker.
Reflector is cheaply cloneable and can either be cloned for each caller or shared between them (for example, via
Arc<T>).
Trait Implementations§
Auto Trait Implementations§
impl<P> Freeze for Reflector<P>
impl<P> RefUnwindSafe for Reflector<P>
impl<P> Send for Reflector<P>
impl<P> Sync for Reflector<P>
impl<P> Unpin for Reflector<P>
impl<P> UnwindSafe for Reflector<P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Track for T
impl<T> Track for T
§fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
Tracked wrapper. Read more§fn in_current_resource_group(self) -> Tracked<Self>
fn in_current_resource_group(self) -> Tracked<Self>
Tracked wrapper. Read more