pub struct UsageLedger { /* private fields */ }Expand description
See the module doc.
Implementations§
Source§impl UsageLedger
impl UsageLedger
pub fn new() -> Self
Sourcepub fn drift_corrections(&self) -> u64
pub fn drift_corrections(&self) -> u64
How many re-measurements by the reconcile pass found a namespace different from what the ledger held — a change no mark reported. Zero on a box whose marks are complete.
Sourcepub fn mark_namespace(&self, namespace: &str)
pub fn mark_namespace(&self, namespace: &str)
Everything about this namespace may have changed: its repositories’ bytes and its tombstones.
Sourcepub fn mark_flow(&self, namespace: &str)
pub fn mark_flow(&self, namespace: &str)
This namespace’s flow moved (the flow ledger’s observer).
Sourcepub fn cursor_now(&self, now_unix_ms: i64) -> String
pub fn cursor_now(&self, now_unix_ms: i64) -> String
The cursor as of now.
Sourcepub fn settle(&self, stores: &ServerStores, sweep: bool) -> Result<()>
pub fn settle(&self, stores: &ServerStores, sweep: bool) -> Result<()>
Bring the ledger up to date with every mark and with the open-store
set — every store that opened or closed since the last settle, and,
with sweep, every store that is open.
Sourcepub fn page(
&self,
stores: &ServerStores,
after: &str,
page_size: usize,
changed_since: &str,
now_unix_ms: i64,
) -> Result<Page>
pub fn page( &self, stores: &ServerStores, after: &str, page_size: usize, changed_since: &str, now_unix_ms: i64, ) -> Result<Page>
One page, in namespace order after after, of at most page_size
namespaces — every one, or with since only those that changed after
it. Settles first. Returns the rows’ namespaces with what is held, and
whether there are more.
Sourcepub fn exact(
&self,
stores: &ServerStores,
namespace: &str,
) -> Result<Option<Exact>>
pub fn exact( &self, stores: &ServerStores, namespace: &str, ) -> Result<Option<Exact>>
One namespace, measured now — what Usage.Read answers: exact, its
own repositories and tombstones walked, nothing else (the index answers
which repositories are its). None for a namespace the catalog does not
hold. Returns the per-repository bytes too, sorted by name.
Sourcepub fn reconcile_step(
&self,
stores: &ServerStores,
tick: Duration,
) -> Result<(usize, usize)>
pub fn reconcile_step( &self, stores: &ServerStores, tick: Duration, ) -> Result<(usize, usize)>
The reconcile pass: re-measure the next slice of namespaces (sized so
the whole set is covered every RECONCILE_CYCLE at a tick cadence),
as if each had been marked. A difference found here is a change no mark
reported: it is corrected (and answered to the next changed-since read)
and counted. Returns (namespaces looked at, corrected).
A pass that cannot run is an Err, never a quiet (0, 0) (A28 M17): the settle
before the slice reads the catalog, and when it cannot be read nothing is re-measured.
Its caller (crate::stores::reconcile_tick) counts the miss
(usage_reconcile_missed on /metrics and in the heartbeat) and warns.
Trait Implementations§
Source§impl Debug for UsageLedger
impl Debug for UsageLedger
Auto Trait Implementations§
impl !Freeze for UsageLedger
impl RefUnwindSafe for UsageLedger
impl Send for UsageLedger
impl Sync for UsageLedger
impl Unpin for UsageLedger
impl UnsafeUnpin for UsageLedger
impl UnwindSafe for UsageLedger
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request