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
impl Quotas
Sourcepub fn set_limit(&self, limit: usize)
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.
Sourcepub fn actor_of(sub: &Submission) -> &str
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.
Sourcepub fn admit(&self, actor: &str) -> Result<Arc<str>, String>
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.
Sourcepub fn release(&self, actor: &Arc<str>)
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.