Skip to main content

CacheProvider

Struct CacheProvider 

Source
pub struct CacheProvider { /* private fields */ }
Expand description

Reloadable runtime cache facade, and the owner of cache.yaml.

CacheRegistry owns driver discovery and candidate construction. This provider owns the active catalog generation: Congif prepares cache.yaml before boot and in the reload batch; configure hands the registry its composition before the sealing boot, and a reload or a prepared source change asks the sealed registry to build and validate a complete replacement, then publishes it atomically. Handles resolved before publication keep their old repository alive; later resolutions see the new generation. An absent file selects the built-in memory store.

Implementations§

Source§

impl CacheProvider

Source

pub fn store(&self, name: &str) -> Result<Arc<CacheRepository>>

Source

pub fn default_store_name(&self) -> Result<String>

Source

pub fn default_store(&self) -> Result<Arc<CacheRepository>>

Source

pub async fn get(&self, key: &str) -> Result<Option<Bytes>>

Source

pub async fn put<'v>( &self, key: &str, value: impl Into<Cow<'v, [u8]>>, ttl: Option<Duration>, ) -> Result<()>

Source

pub async fn get_value(&self, key: &str) -> Result<Option<CacheValue>>

Source

pub async fn put_value( &self, key: &str, value: CacheValue, ttl: Option<Duration>, ) -> Result<()>

Source

pub fn supports_tags(&self) -> Result<bool>

Whether the default store accepts tagged operations; see CacheRepository::supports_tags.

Source

pub async fn put_tagged<'v>( &self, key: &str, value: impl Into<Cow<'v, [u8]>>, ttl: Option<Duration>, tags: &[&str], ) -> Result<()>

Source

pub async fn put_value_tagged( &self, key: &str, value: CacheValue, ttl: Option<Duration>, tags: &[&str], ) -> Result<()>

Source

pub async fn invalidate_tags(&self, tags: &[&str]) -> Result<()>

Source

pub async fn forget(&self, key: &str) -> Result<()>

Source

pub async fn clear(&self) -> Result<()>

Trait Implementations§

Source§

impl Bootable<State> for CacheProvider

Source§

fn boot<'life0, 'life1, 'async_trait>( &'life0 self, _deps: (), _state: &'life1 AppState, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

impl Component<State> for CacheProvider

Source§

type Deps = ()

What this component requires. See the trait documentation.
Source§

fn name(&self) -> &'static str

Stable lifecycle label for logs and diagnostics. The default single runnable uses this as its management name; factories name each instance.
Source§

fn validate(&self, _state: &AppState) -> Result<()>

Synchronous readiness validation after boot and before runnables are spawned: cheap checks over boot-published state, missing files or conflicting settings.
Source§

fn as_reloadable(&self) -> Option<&dyn Reloadable<AppState>>

Optional capability hook.
Source§

fn as_configurable(&self) -> Option<&dyn ConfigRegistration>

Optional typed configuration owned by this component.
Source§

fn as_bootable(&self) -> Option<&dyn Bootable<AppState, Self::Deps>>

Optional ordered preparation. Operational work belongs to Runnable.
Source§

fn boot_priority(&self) -> Option<u8>

Boot order among components that are otherwise independent. Lower runs earlier; None means priority::NORMAL.
Source§

fn run_priority(&self) -> Option<u8>

Runnable submission order among otherwise-ready components. Lower is submitted earlier; None means priority::NORMAL. This grants neither poll priority nor an operational readiness barrier.
Source§

fn order(&self) -> ComponentOrder

Placement relative to layers or boot-time producers of plain DI values. Dependencies on other components belong in Deps.
Source§

fn as_any(&self) -> &(dyn Any + 'static)
where Self: Sized,

Downcast hook for typed resolve APIs.
Source§

fn as_scoped(&self) -> Option<&dyn Scoped>

Optional placement metadata for an application-owned fleet adapter. The default is treated as Scope::Worker. The runtime consults this before creating local runnable entries; registration is unaffected.
Source§

fn as_dispatched(&self) -> Option<&dyn Dispatched>

Optional dispatch metadata for a fleet execution adapter. Absent means Dispatch::Each. It applies to runnable execution, not to construction, boot or configuration.
Source§

fn as_environmental(&self) -> Option<&dyn Environmental>

Optional declaration of the environments this component’s programs start with. Asked after configure and after a reload; a re-read file is delivered through Environmental::environment_changed.
Source§

fn as_finalizable(&self) -> Option<&dyn Finalizable<S>>

Optional capability hook.
Source§

fn as_runnable(self: Arc<Self>) -> Option<Arc<dyn Runnable<S, Self::Deps>>>

Optional capability hook. The runnable receives this component’s resolved Deps on every generation.
Source§

fn runnables(self: Arc<Self>) -> Vec<RunnableInstance<S>>
where S: Send + Sync + 'static,

Enumerate this component’s named operational instances after preparation. The default exposes the optional single runnable under the component name. Override to produce multiple instances from configuration; enumeration must not bind listeners or start tasks. Retain unchanged instance handles.
Source§

impl ConfigObserver for CacheProvider

Source§

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

Before the registry seals, the newest preparation is what boot builds; after it, a changed file is a new catalog generation.

Source§

impl Configurable for CacheProvider

Source§

fn absent_source(&self) -> Option<CacheConfig>

An absent file selects the registry’s built-in memory store.

Source§

type Config = CacheConfig

Congif compares prepared and applied configurations using this type’s equality, without asking the provider to retain or compare snapshots.
Source§

fn source(&self) -> ConfigFile

One source with an explicit parser format. Reading is owned by the reader.
Source§

fn validate_config(&self, config: &CacheConfig) -> Result<()>

Validate semantic consistency of a prepared candidate before publication. Serde checks types and declared deserialization rules; this hook checks interdependent parameters and runtime-specific constraints that those rules cannot express. Config-local checks may be delegated to the config’s own validation method. Validation must not change live runtime resources.
Source§

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

Apply the prepared startup config. Reading and validation have finished; this hook may initialize runtime resources without parsing again. A declaration consumed by a later boot constructor needs no application hook: its validated snapshot remains available in the reader.
Source§

fn as_config_observer( &self, ) -> Option<&dyn ConfigObserver<Config = Self::Config>>

Opt in to source notifications after a validated candidate is prepared. Reading a source does not, by itself, request automatic watching.
Source§

fn read_config<'life0, 'life1, 'async_trait>( &'life0 self, reader: &'life1 ConfigReader, ) -> Pin<Box<dyn Future<Output = Result<Self::Config, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: Sized + 'static + 'async_trait,

Read the candidate the reader then validates and compares. The default reads the declared source, answering an absent file with absent_source. Congif records the includes a document names and watches them, but opens none of them: an owner whose document is completed by its includes merges them here, reading each through ConfigReader::read_include so it is parsed with the owner’s environment and its own includes are recorded. The merged value is what equality compares, so a change inside an include is a changed config.
Source§

fn as_partial_config_observer( &self, ) -> Option<&dyn PartialConfigObserver<Config = Self::Config>>

Opt in to independently watched partial sources. Ordinary owners keep their existing full-document preparation and observation path.
Source§

fn environment(&self) -> Option<&EnvHandle>

Select a registered environment for configuration preparation. None uses the reader’s application-owned binding, if any. This is not the environment supplied to a child process or hosted application.
Source§

fn namespace(&self) -> String

Configuration namespace, independent of the owner’s runtime identity. Defaults to the unqualified type name in snake_case; override this to expose a stable public name such as http instead of http_provider. Generic arguments do not participate in the default namespace.
Source§

fn export_config(&self, _config: &Self::Config) -> Result<Option<Value>, Error>

Opt in to dot-path access for hosted applications and language bridges. Export only fields intended for those consumers. Called during preparation, never during lookup; typed Rust access needs no export. When the whole configuration is meant for them and it serializes, congif::export(config) is the one-line body.
Source§

impl Register<State> for CacheProvider

Source§

impl Reloadable<State> for CacheProvider

Source§

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

Perform a synchronous reload using the current shared state. Implementations may spawn async work internally if needed. Read more
Source§

fn priority(&self) -> Option<u8>

Optional reload priority. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<S, C> AnyComponent<S> for C
where S: Send + Sync + 'static, C: Component<S>,

Source§

fn name(&self) -> &str

Source§

fn boot_priority(&self) -> Option<u8>

Source§

fn run_priority(&self) -> Option<u8>

Source§

fn order(&self) -> ComponentOrder

Source§

fn dependencies(&self) -> Vec<TypeId>

The TypeIds named by the component’s Deps.
Source§

fn has_bootable(&self) -> bool

Whether the component exposes a Bootable.
Source§

fn boot<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, registry: &'life1 Registry<S>, state: &'life2 S, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, C: 'async_trait,

Resolve the component’s dependencies and run its Bootable, if any.
Source§

fn validate(&self, state: &S) -> Result<(), Error>

Source§

fn as_reloadable(&self) -> Option<&dyn Reloadable<S>>

Source§

fn as_finalizable(&self) -> Option<&dyn Finalizable<S>>

Source§

fn runnables(self: Arc<C>) -> Vec<RunnableInstance<S>>

Expose runnable instances without resolving dependencies. The runtime checks scope and activation policy before binding an admitted generation.
Source§

fn as_configurable(&self) -> Option<&(dyn ConfigRegistration + 'static)>

Source§

fn as_environmental(&self) -> Option<&dyn Environmental>

Source§

fn as_scoped(&self) -> Option<&dyn Scoped>

Source§

fn as_dispatched(&self) -> Option<&dyn Dispatched>

Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ConfigRegistration for T
where T: Configurable + 'static,

Source§

fn source(&self) -> ConfigFile

Source§

fn configure<'life0, 'life1, 'async_trait>( &'life0 self, config: &'life1 (dyn Any + Sync + Send + 'static), ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, T: 'async_trait,

Source§

fn observes_config(&self) -> bool

Source§

fn partial_sources( &self, reader: &ConfigReader, ) -> Result<Option<Vec<PathBuf>>, Error>

Source§

fn prepare_partial_config<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, reader: &'life1 ConfigReader, sources: &'life2 [PathBuf], ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn Any + Sync + Send>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, T: 'async_trait,

Source§

fn partial_config_changed<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, config: &'life1 (dyn Any + Sync + Send + 'static), sources: &'life2 [PathBuf], ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, T: 'async_trait,

Source§

fn environment(&self) -> Option<&EnvHandle>

Source§

fn config_changed<'life0, 'life1, 'async_trait>( &'life0 self, config: &'life1 (dyn Any + Sync + Send + 'static), ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, T: 'async_trait,

Source§

fn exported_config( &self, config: &(dyn Any + Sync + Send + 'static), ) -> Result<Option<(String, Value)>, Error>

Source§

fn same_config( &self, previous: &(dyn Any + Sync + Send + 'static), candidate: &(dyn Any + Sync + Send + 'static), ) -> bool

Source§

fn prepare_config<'life0, 'life1, 'async_trait>( &'life0 self, reader: &'life1 ConfigReader, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn Any + Sync + Send>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, T: 'async_trait,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more