pub struct Metering {
pub function: String,
pub invocations: u64,
pub successes: u64,
pub failures: u64,
pub duration_ms_total: u64,
pub bytes_in_total: u64,
pub bytes_out_total: u64,
pub window_start: u64,
pub window_count: u64,
pub updated: u64,
}Expand description
Host-side usage aggregate for one function (FA-4), tenant-isolated under
keys::metering. It also carries the fixed-window rate-limit counter so
metering + quota share a single read-modify-write.
Fields§
§function: StringThe function these counters belong to.
invocations: u64Total invocations metered (sync + drained async).
successes: u64Invocations whose guest produced a response.
failures: u64Invocations that failed to deliver (engine error / dead-lettered).
duration_ms_total: u64Summed wall-clock duration, milliseconds.
bytes_in_total: u64Summed request bytes.
bytes_out_total: u64Summed response bytes.
window_start: u64The current rate-limit window’s start (unix seconds).
window_count: u64Invocations admitted in the current window.
updated: u64Last update (unix seconds).
Implementations§
Source§impl Metering
impl Metering
Sourcepub fn record(&mut self, sample: &MeteringSample, now: u64)
pub fn record(&mut self, sample: &MeteringSample, now: u64)
Fold one invocation’s cost into the usage counters.
Sourcepub fn admit(&mut self, quota: &FunctionQuota, now: u64) -> bool
pub fn admit(&mut self, quota: &FunctionQuota, now: u64) -> bool
Admit one invocation against the fixed-window rate limit, rolling the
window over when it has elapsed. Returns true if admitted (and records
the admission), false if the window is already at max (⇒ the caller
fails closed with 429). An unset cap always admits.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Metering
impl<'de> Deserialize<'de> for Metering
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Metering, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Metering, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for Metering
Source§impl Serialize for Metering
impl Serialize for Metering
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Metering
Auto Trait Implementations§
impl Freeze for Metering
impl RefUnwindSafe for Metering
impl Send for Metering
impl Sync for Metering
impl Unpin for Metering
impl UnsafeUnpin for Metering
impl UnwindSafe for Metering
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.