ClientHandle

Struct ClientHandle 

Source
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: ServerSessionCore

Protocol-erased server session state machine.

§module: Option<Module>

Module the client has linked to, if any.

§last_heard: Instant

Last time we received a datagram from this client.

§access: AccessPolicy

Access policy granted by the authorizer.

§send_failure_count: u32

Monotonically increasing count of fan-out send failures.

§tx_budget: TokenBucket

Per-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>

Source

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.

Source

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.

Trait Implementations§

Source§

impl<P: Debug + Protocol> Debug for ClientHandle<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<P> Freeze for ClientHandle<P>

§

impl<P> RefUnwindSafe for ClientHandle<P>

§

impl<P> Send for ClientHandle<P>

§

impl<P> Sync for ClientHandle<P>

§

impl<P> Unpin for ClientHandle<P>

§

impl<P> UnwindSafe for ClientHandle<P>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more