Expand description
An opt-in admission gate for sends: a capacity, slots reserved per tenant, a bounded wait, priority classes and weighted fairness, all set by the server (audit H9, ADR 0045).
Without one, which is the default, a send the server has no room for is
refused at once with Overloaded (503 with Retry-After). With one:
- at most
Admission::capacityturns run at once through the gate; - a tenant given
TenantShare::with_reservedslots can always take them, and no other tenant can; - a send that finds no slot waits, if the queue has room
(
Admission::with_max_queued), for at mostAdmission::with_max_waitor what remains of its budget, whichever is shorter; - a freed slot goes to the highest priority
with a send waiting, and within a priority round the tenants waiting,
weightsends each per round.
The tenant is the one the handler resolved for the request
(TenantResolver); nothing the caller sends sets
a priority.
use std::time::Duration;
use a2a_protocol_server::admission::{Admission, TenantShare};
let admission = Admission::new(256)
.with_max_queued(1024)
.with_max_wait(Duration::from_millis(500))
.with_tenant(
"premium",
TenantShare::new().with_priority(1).with_weight(4).with_reserved(32),
);
assert_eq!(admission.capacity(), 256);
assert_eq!(admission.share("premium").reserved(), 32);
assert_eq!(admission.share("anyone").weight(), 1);Structs§
- Admission
- The admission gate’s configuration; see the module docs. Set it
with
RequestHandlerBuilder::with_admission. - Admission
Load - What an admission gate holds now: see
RequestHandler::admission_load. - Tenant
Share - What one tenant gets from an
Admissiongate.