Skip to main content

CachedRegistryProvider

Struct CachedRegistryProvider 

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

The coherence contract as a type (ADR-019 §4, POC-R’s named deliverable; substrate.md §the coherence contract) — the cached read provider the advertisement path rides:

  • Cached set: the whole record table as one immutable snapshot — an Arc map swapped under a short lock. Whole-table is deliberate: record tables are small, whole snapshots make coalesced refreshes trivially correct (a refresh re-reads the table; there is no delta application to get wrong), and readers never block a writer.
  • Hot path: one lock read + Arc clone + lookup. Zero I/O on the steady state — the provider holds no durable-side handle at all; it serves last-installed state and nothing else.
  • Invalidation triggers: (1) alkstore wakes (the post-commit notify hint, or sqlite’s file-wide data_version bump from any writer — the delivery wiring is the reactor’s wake runner); (2) the provider’s own writes (write-through, via CachedRegistryProvider::install_one / CachedRegistryProvider::install_removal — the RegistryBackend store methods call these); (3) the reconcile tick (driven through CachedRegistryProvider::refresh_from, the same body the wake handler runs).
  • Staleness bound: mutation visibility ≤ one wake delivery + one refresh. One refresh_from after a mutation is always enough to surface it — the snapshot is whole-table, so there is no partial state between installs.
  • Refresh coalescing: correct by the snapshot swap — a burst of mutations collapses into one refresh, and one refresh carries the whole burst.
  • Failure posture: refresh failures leave the previous snapshot serving; the next wake, write, or tick retries.

Implementations§

Source§

impl CachedRegistryProvider

Source

pub fn new() -> Self

A provider with an empty snapshot.

Source

pub fn install(&self, rows: Vec<RegistryRow>)

Install a whole-table snapshot (the wake handler’s and the reconcile tick’s body — a swap, not a delta).

Source

pub fn install_one(&self, row: RegistryRow)

Write-through install of one row — the store’s own write path (no table read involved).

Source

pub fn install_removal(&self, repo_id: &str)

Write-through removal — the store’s own removal path.

Source

pub async fn refresh_from( &self, registry: &dyn RegistryWrite, ) -> Result<(), RegistryError>

Pull-and-install from the durable side — the body the wake handler and the reconcile tick both run. The whole table is re-read (rows_since(0)) and swapped in; on failure nothing is installed and the previous snapshot keeps serving.

Source

pub fn snapshot(&self) -> Arc<HashMap<String, RepoRecord>> ⓘ

The installed snapshot (observation without refresh — replication-style consumers and the tests’ coherence asserts).

Source

pub fn refresh_count(&self) -> u64

How many installs have landed (test-observation for the refresh-count pins: idle-stability across idle windows, one refresh per coalesced burst).

Trait Implementations§

Source§

impl Default for CachedRegistryProvider

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl RegistryRead for CachedRegistryProvider

Source§

fn resolve(&self, repo_id: &str) -> Option<RepoRecord>

Resolve a repo id to its record; None is a definitive miss.

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<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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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