Skip to main content

UsageLedger

Struct UsageLedger 

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

See the module doc.

Implementations§

Source§

impl UsageLedger

Source

pub fn new() -> Self

Source

pub fn epoch(&self) -> &str

This ledger’s epoch: a cursor from another is “everything”.

Source

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.

Source

pub fn mark_repo(&self, namespace: &str, name: &str)

This repository’s bytes may have changed.

Source

pub fn mark_namespace(&self, namespace: &str)

Everything about this namespace may have changed: its repositories’ bytes and its tombstones.

Source

pub fn mark_flow(&self, namespace: &str)

This namespace’s flow moved (the flow ledger’s observer).

Source

pub fn mark_all(&self)

Everything may have changed (a growth’s remount, a role change).

Source

pub fn cursor_now(&self, now_unix_ms: i64) -> String

The cursor as of now.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for UsageLedger

Source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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