pub struct Reflector<P: Processor> { /* private fields */ }
Expand description
Reflector
composes a source of data with a processor that is 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 are 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 async fn new<S, I>(source: S, processor: P) -> Self
pub async fn new<S, I>(source: S, processor: P) -> Self
Creates a new reflector with the given data source and processor.
A reflector composes a source of data with a processor that is used to transform the data, and then stores the 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.
A task will be spawned that drives consumption of the data source and processes the items, feeding them into the
reflector state, which can be queried from the returned Reflector.
Reflector
is cheaply cloneable and can either be cloned for each caller or shared between them (e.g., 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::Request
Source§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Track for T
impl<T> Track for T
§fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
Tracked
wrapper. Read more§fn in_current_allocation_group(self) -> Tracked<Self>
fn in_current_allocation_group(self) -> Tracked<Self>
Tracked
wrapper. Read more