Skip to main content

Quotas

Struct Quotas 

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

Shared per-actor in-flight counts. Cloneable; every clone refers to the same table.

Implementations§

Source§

impl Quotas

Source

pub fn new(limit: usize) -> Self

A table enforcing limit ops in flight per actor.

Source

pub fn set_limit(&self, limit: usize)

Changes the ceiling for subsequent admissions.

Lowering it never revokes an admission already granted: ops in flight are already the writer’s business, and refusing them retroactively would break the promise that a submission is either answered or rejected, not abandoned.

Source

pub fn limit(&self) -> usize

The current ceiling.

Source

pub fn actor_of(sub: &Submission) -> &str

The bucket a submission counts against.

Signed ops are keyed by their claimed key id. Unsigned ones fall back to the channel, which keeps the pre-L8 and dev paths from collapsing into one shared bucket where every workspace would throttle every other.

Source

pub fn admit(&self, actor: &str) -> Result<Arc<str>, String>

Takes a slot for actor, returning the interned key to release it with.

The interning is not a micro-optimization for its own sake: this runs on every submission, and alloc_budget asserts a ceiling on allocator calls per op. Handing back a shared Arc<str> means the per-op cost after an actor’s first op is a refcount rather than a string copy.

§Errors

A rejection naming the quota, when actor already has limit ops awaiting a decision.

Source

pub fn release(&self, actor: &Arc<str>)

Returns a slot, once the writer has decided that op.

Released at the decision rather than at the acknowledgement: the quota bounds how much work can be queued ahead of someone else, and once an op is appended it is no longer ahead of anything. Ops waiting on a shared durability barrier have already had their ordering cost paid by whoever was behind them.

Source

pub fn in_flight(&self, actor: &str) -> usize

Ops from actor currently awaiting a decision. For tests and operator reporting.

Trait Implementations§

Source§

impl Clone for Quotas

Source§

fn clone(&self) -> Quotas

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 Default for Quotas

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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> 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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.