pub struct ClientHandle<P: Protocol> {
pub session: ServerSessionCore,
pub module: Option<Module>,
pub last_heard: Instant,
pub access: AccessPolicy,
pub send_failure_count: u32,
pub tx_budget: TokenBucket,
/* private fields */
}Expand description
One entry in super::ClientPool.
Tracks the per-peer server session, its module membership (if any), the last time we heard from the client, the access policy the authorizer granted, a running count of send failures so the fan-out engine can evict unhealthy peers, and a per-client TX token bucket used to rate-limit how many fan-out voice frames one client can consume per second.
Fields§
§session: ServerSessionCoreProtocol-erased server session state machine.
module: Option<Module>Module the client has linked to, if any.
last_heard: InstantLast time we received a datagram from this client.
access: AccessPolicyAccess policy granted by the authorizer.
send_failure_count: u32Monotonically increasing count of fan-out send failures.
tx_budget: TokenBucketPer-client TX token bucket. Each outbound voice frame in fan-out consumes one token; when the bucket is empty, the frame is dropped for THIS peer (the other peers on the same module still receive it). Rate-limited is NOT the same as broken — the peer is not marked unhealthy.
Implementations§
Source§impl<P: Protocol> ClientHandle<P>
impl<P: Protocol> ClientHandle<P>
Sourcepub fn new(
session: ServerSessionCore,
access: AccessPolicy,
now: Instant,
) -> Self
pub fn new( session: ServerSessionCore, access: AccessPolicy, now: Instant, ) -> Self
Construct a new handle for a freshly observed client.
The TX budget is initialized with DEFAULT_TX_BUDGET_MAX_TOKENS
capacity and DEFAULT_TX_BUDGET_REFILL_PER_SEC refill rate.
Sourcepub fn new_with_tx_budget(
session: ServerSessionCore,
access: AccessPolicy,
now: Instant,
max_tokens: u32,
refill_rate_per_sec: f64,
) -> Self
pub fn new_with_tx_budget( session: ServerSessionCore, access: AccessPolicy, now: Instant, max_tokens: u32, refill_rate_per_sec: f64, ) -> Self
Construct a new handle with a caller-specified TX budget.
Primarily used by tests that need to drive the rate limiter past its limit in a single tick without waiting for real wall-clock refill.