pub struct EntitlementReader { /* private fields */ }Implementations§
Source§impl EntitlementReader
impl EntitlementReader
pub fn new(store: Arc<CacheStore>, identity: Arc<IdentityManager>) -> Self
pub fn with_http(self, http: Arc<HttpClient>) -> Self
pub fn with_observer_bus(self, bus: Arc<ObserverBus>) -> Self
pub fn with_clock(self, clock: Arc<dyn Clock>) -> Self
Sourcepub fn with_max_offline_grace_ms(self, grace_ms: u64) -> Self
pub fn with_max_offline_grace_ms(self, grace_ms: u64) -> Self
Override the maximum offline grace (see
DEFAULT_MAX_OFFLINE_GRACE_MS). Reads older than this report
inactive until a refresh succeeds.
Sourcepub fn get(&self, id: &str) -> RovenueResult<Option<Entitlement>>
pub fn get(&self, id: &str) -> RovenueResult<Option<Entitlement>>
One entitlement by id. Enforces the offline policy on the cached
row (see Self::apply_offline_policy): an expired or
grace-lapsed row reads back with is_active == false.
Sourcepub fn list_all(&self) -> RovenueResult<Vec<Entitlement>>
pub fn list_all(&self) -> RovenueResult<Vec<Entitlement>>
All cached entitlements. Each row goes through the same offline
policy as Self::get; lapsed rows are returned with
is_active == false, never silently dropped.
pub fn refresh(&self) -> RovenueResult<()>
Sourcepub fn hydrate(
&self,
scope: &str,
map: HashMap<String, EntitlementWire>,
now: u64,
) -> RovenueResult<()>
pub fn hydrate( &self, scope: &str, map: HashMap<String, EntitlementWire>, now: u64, ) -> RovenueResult<()>
Write entitlements straight from an in-memory access map (e.g. a receipt POST response) — no network. Stamps freshness and emits the observer.
Sourcepub fn maybe_refresh_async(self: &Arc<Self>, staleness_ms: u64)
pub fn maybe_refresh_async(self: &Arc<Self>, staleness_ms: u64)
Non-blocking stale-while-revalidate trigger. Returns immediately; if the
cache is stale and no refresh is in flight, spawns one background refresh
(coalesced via refreshing) that emits the observer on completion.