pub struct DispatchCache { /* private fields */ }Expand description
Host-owned dispatch cache. Construct once, share via Arc<DispatchCache>
across all CmfPluginInvoker::for_request calls so plans built for
one request can be reused by the next.
Cache key is the APL route_key. Entries pair with the cpex-core
snapshot generation observed at build time; a mismatch on lookup
triggers eviction and rebuild. v0 keys on route_key only —
entity-aware caching (entity_type/entity_name from MetaExtension)
is a follow-up when per-tenant lineup variation lands.
Implementations§
Source§impl DispatchCache
impl DispatchCache
pub fn new() -> DispatchCache
Sourcepub async fn get_or_build(
&self,
route: &CompiledRoute,
registry: &HashMap<String, PluginDeclaration>,
manager: &PluginManager,
) -> Arc<RouteDispatchPlan>
pub async fn get_or_build( &self, route: &CompiledRoute, registry: &HashMap<String, PluginDeclaration>, manager: &PluginManager, ) -> Arc<RouteDispatchPlan>
Get-or-build a plan for the route. Read-locked fast path returns the cached plan when the generation matches; otherwise drop the read lock, rebuild, and write-lock-insert. The brief window between read-miss and write-insert may let two concurrent builders race — both produce identical plans and the second insert just overwrites the first. Cheap relative to the cost of the build itself, and avoids holding a write lock across the build call.
Async because RouteDispatchPlan::build may invoke
PluginManager::build_override_entries, which calls plugin
factories and initialize() for routes that declare config:
overrides. Routes with no overrides take a synchronous path
inside the manager (no .await does any real work), so the
async cost is zero for the common case.
Trait Implementations§
Source§impl Default for DispatchCache
impl Default for DispatchCache
Source§fn default() -> DispatchCache
fn default() -> DispatchCache
Auto Trait Implementations§
impl !Freeze for DispatchCache
impl RefUnwindSafe for DispatchCache
impl Send for DispatchCache
impl Sync for DispatchCache
impl Unpin for DispatchCache
impl UnsafeUnpin for DispatchCache
impl UnwindSafe for DispatchCache
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind referenceSource§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable referenceSource§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointerSource§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointerSource§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, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more