pub struct ClientRegistry { /* private fields */ }Expand description
Central tracker for all accepted client connections. Constructed once
per halephant process and shared via Arc.
Implementations§
Source§impl ClientRegistry
impl ClientRegistry
pub fn new() -> Self
Sourcepub fn register(self: &Arc<Self>, remote: SocketAddr) -> ClientGuard
pub fn register(self: &Arc<Self>, remote: SocketAddr) -> ClientGuard
Register a newly accepted client and return the RAII guard that
owns its entry. The initial state is ClientState::Negotiating;
the caller should transition to ClientState::Authenticating
once the startup message has been parsed.
Sourcepub fn snapshot(&self) -> Vec<ClientEntry>
pub fn snapshot(&self) -> Vec<ClientEntry>
Return a clone of every currently-registered client entry. Used
by the admin /admin/clients handler. The lock is held only for
the duration of the clone.
Sourcepub fn counts_by_state(&self) -> [(ClientState, u64); 5]
pub fn counts_by_state(&self) -> [(ClientState, u64); 5]
Count clients by state in a single locked pass.
Returns a fixed-size array of (state, count) pairs covering
every ClientState variant. Used by the
halephant.client.connections observable gauge — reading all
five buckets from the same snapshot keeps the gauge
self-consistent and touches the mutex exactly once per
observation cycle.