pub struct CachingRoutingStore { /* private fields */ }Expand description
Wraps any RoutingStore with a per-org RoutingEngine cache.
The cache also implements RoutingStore so callers can swap it in
without changing wiring. Prefer CachingRoutingStore::engine_for when
you actually want the pre-built engine — that’s the hot path.
Implementations§
Source§impl CachingRoutingStore
impl CachingRoutingStore
pub fn new(inner: Arc<dyn RoutingStore>) -> Self
pub fn with_ttl(inner: Arc<dyn RoutingStore>, ttl: Duration) -> Self
Sourcepub async fn engine_for(
&self,
org_id: Uuid,
) -> Result<Arc<RoutingEngine>, RoutingStoreError>
pub async fn engine_for( &self, org_id: Uuid, ) -> Result<Arc<RoutingEngine>, RoutingStoreError>
Hot path. Returns the cached engine for org_id when fresh, otherwise
refreshes from the underlying store. Errors from the backend propagate
— callers should treat them as “no routes” and dispatch unchanged.
Sourcepub async fn invalidate(&self, org_id: Uuid)
pub async fn invalidate(&self, org_id: Uuid)
Manually drop the cached entry for org_id. Used by tests; could
later be wired to an admin “force refresh” endpoint.
Trait Implementations§
Source§impl Debug for CachingRoutingStore
impl Debug for CachingRoutingStore
Source§impl RoutingStore for CachingRoutingStore
impl RoutingStore for CachingRoutingStore
Source§fn list_for_org<'life0, 'async_trait>(
&'life0 self,
org_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<Route>, RoutingStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_for_org<'life0, 'async_trait>(
&'life0 self,
org_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<Route>, RoutingStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Fetch the enabled-and-current route list for
org_id. Returns
Ok(vec![]) when the org has no routes — not an error.Source§fn list_all_for_org<'life0, 'async_trait>(
&'life0 self,
org_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<Route>, RoutingStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_all_for_org<'life0, 'async_trait>(
&'life0 self,
org_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<Route>, RoutingStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Management: ALL of an org’s routes, including disabled ones.
Source§fn create_route<'life0, 'async_trait>(
&'life0 self,
org_id: Uuid,
spec: NewRoute,
) -> Pin<Box<dyn Future<Output = Result<Route, RoutingStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create_route<'life0, 'async_trait>(
&'life0 self,
org_id: Uuid,
spec: NewRoute,
) -> Pin<Box<dyn Future<Output = Result<Route, RoutingStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Management: create a route for
org_id. Returns the created route.Source§fn get_route<'life0, 'async_trait>(
&'life0 self,
org_id: Uuid,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<Route>, RoutingStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_route<'life0, 'async_trait>(
&'life0 self,
org_id: Uuid,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<Route>, RoutingStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Management: fetch one route owned by
org_id.Source§fn delete_route<'life0, 'async_trait>(
&'life0 self,
org_id: Uuid,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<bool, RoutingStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete_route<'life0, 'async_trait>(
&'life0 self,
org_id: Uuid,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<bool, RoutingStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Management: delete one route owned by
org_id. Returns whether a row was removed.Auto Trait Implementations§
impl !Freeze for CachingRoutingStore
impl !RefUnwindSafe for CachingRoutingStore
impl !UnwindSafe for CachingRoutingStore
impl Send for CachingRoutingStore
impl Sync for CachingRoutingStore
impl Unpin for CachingRoutingStore
impl UnsafeUnpin for CachingRoutingStore
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
Mutably borrows from an owned value. Read more