Skip to main content

SpendJournal

Struct SpendJournal 

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

A persistent spend journal. Clones share it.

Implementations§

Source§

impl SpendJournal

Source

pub fn open( path: impl AsRef<Path>, kind: BudgetKind, clock: Arc<dyn SpendClock>, ) -> Result<Self, JournalError>

Open the journal at path, creating it with a header for kind if it does not exist. Migrates a testing header that names the superseded cap (see the module documentation). Refuses a journal of another budget, cap or schema, a journal another writer holds, and complete lines that do not parse.

Source

pub fn budget(&self) -> BudgetKind

Source

pub fn path(&self) -> &Path

Source

pub fn write_failures(&self) -> u64

Lines that could not be written after a reservation (settlements, reconciliations, releases). Each leaves the journal counting more, never less.

Source

pub fn reserve( &self, attempt_id: &str, units: u64, ) -> Result<Reservation, SpendRefusal>

Reserve units for attempt_id in the current period, durably, or refuse. Refused means: do not send.

Source

pub fn settle(&self, r: Reservation, charge: Charge)

Settle a reservation with the attempt’s charge: observed and estimated charges replace it; unknown keeps it as liability.

Source

pub fn release(&self, r: Reservation)

Release a reservation whose request was never sent.

Source

pub fn reconcile(&self, seq: u64, observed_units: u64) -> bool

A later observed charge for a reservation held as liability (spec 003, 3.5.5). False when it holds none.

Source

pub fn reconcile_billing( &self, journal_credential_reference: &str, billing: &BillingSettlement, ) -> Result<(), Unresolved>

Spec 022: settle production liability only from a provider billing line for the journal’s credential and the reservation’s own month. The host must retain the billing line as evidence; no credential value is accepted or recorded here.

Source

pub fn summary(&self) -> SpendSummary

The totals of the current period.

Source

pub fn run_spend(&self, run_id: &str) -> u64

Committed units for attempt ids starting with live/<run_id>/. Counts observed, estimated, liability and outstanding amounts across periods; released reservations contribute nothing. Replayed reservation state at open preserves this total across a restart.

Source

pub fn reservations_for(&self, decision_id: &str) -> Vec<String>

Runtime attempt ids in reservation sequence order, including releases.

Source

pub fn reservations_detail(&self, decision_id: &str) -> Vec<CaseSpend>

Reservation evidence for exactly this decision, in journal sequence order. Unsettled and crash liability remain unknown, never an inferred charge.

Source

pub fn run_split(&self, run_id: &str) -> RunSpend

Source

pub fn testing_header_digest() -> ContentDigest

Schema-tagged digest of the serialized testing header, including newline.

Source

pub fn superseded_testing_header_digest() -> ContentDigest

Self::testing_header_digest of a testing journal under the superseded cap, before its header was migrated (A-75).

Source

pub fn headroom(&self) -> u64

Units still available in the current period.

Source

pub fn runtime_cost_policy(&self) -> CostPolicy

The cost policy for a runtime’s shared ledger holding the current headroom: estimates are reserved, so an attempt that does not fit is recorded budget_exhausted{cost} by the runtime before it reaches the adapter (spec 003, 3.5.3). The journal’s own check stays as the backstop.

Source

pub fn shared_runtime_ledger(&self) -> Arc<Ledger> ⓘ

A runtime shared ledger seeded with the current headroom, for RuntimeBuilder::shared_ledger.

Trait Implementations§

Source§

impl Clone for SpendJournal

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SpendJournal

Source§

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

Formats the value using the given formatter. 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<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.