Skip to main content

CacheServiceConfigSource

Trait CacheServiceConfigSource 

Source
pub trait CacheServiceConfigSource: Send + Sync {
    // Required methods
    fn load<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<CacheNamespaceConf>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn subscribe<'life0, 'async_trait>(
        &'life0 self,
        on_update: Arc<dyn Fn(CacheNamespaceConf) + Send + Sync>,
    ) -> Pin<Box<dyn Future<Output = Result<SubscriptionHandle>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Supplies a live, possibly-changing namespace configuration. CacheService does not poll: the source detects changes and pushes them by invoking the on_update callback registered via CacheServiceConfigSource::subscribe.

Implement this interface in the application for configuration loading and updates.

Required Methods§

Source

fn load<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<CacheNamespaceConf>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Loads the initial namespace configuration. Called once at construction.

Source

fn subscribe<'life0, 'async_trait>( &'life0 self, on_update: Arc<dyn Fn(CacheNamespaceConf) + Send + Sync>, ) -> Pin<Box<dyn Future<Output = Result<SubscriptionHandle>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribes to subsequent changes. The source invokes on_update whenever the namespace configuration changes; CacheService never polls. Dropping the returned SubscriptionHandle cancels the subscription (and releases its polling/listening resources). Replay current state when registering to cover changes after load, then deliver updates in source order. Shared polling may continue while other subscribers remain.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§