pub struct ListenerConfig {
pub addr: SocketAddr,
pub idle_timeout: Duration,
pub slow_threshold: Duration,
pub auth_required: bool,
pub tls: Option<ServerTls>,
pub max_connections: usize,
pub observer: Option<Arc<dyn MetricsObserver>>,
}Expand description
Listener configuration. Family posture keeps binds loopback/private by default (SRV-040 guidance).
Fields§
§addr: SocketAddrAddress to bind. Port 0 picks an ephemeral port — read it back
via ListenerHandle::local_addr.
idle_timeout: DurationPer-read idle timeout (slow-loris resistance, SRV-009). Zero disables, matching each product’s current posture.
slow_threshold: DurationCommands slower than this bump slow_commands_total (SRV-030).
Zero disables the counter.
auth_required: boolWhether this deployment enforces credentials (SRV-011).
This is policy, not protocol: the profile fixes the handshake
shape (does the client lead with HELLO? does it authenticate via
AUTH?), while this flag decides whether the server actually refuses
un-credentialed sessions. Both family products that authenticate on
the RPC path expose exactly this toggle — Nexus’s auth_required and
Synap’s require_auth — and an open Synap deployment is the reason
it must live here rather than in the profile.
Ignored under Handshake::None, which has no gate at all. Defaults
to true: a deployment opens up only by saying so.
tls: Option<ServerTls>Optional TLS (SRV-040 / SPEC-008 CAN-020). Some turns TLS on for this
deployment; None (the default) keeps it plaintext. Requires the crate’s
tls feature — a listener configured with TLS but built without it fails
to start rather than silently serving plaintext.
max_connections: usizeMaximum concurrently open connections; further accepts are refused.
0 (the default) means unbounded.
This is a different resource from Config::max_in_flight, which
bounds in-flight requests per connection: ten thousand idle
connections each hold a reader task, a writer task and a BufWriter
no matter what max_in_flight says. Operators bound memory and
slow-loris exposure with this knob — Synap’s network.max_connections
is exactly it.
Refusal, not queueing: at capacity the socket is dropped
immediately, so a client fails fast instead of hanging on a connection
nobody will ever read. Each refusal increments
MetricsSnapshot::connections_refused_total, so a ceiling that is
engaging is visible rather than silent.
observer: Option<Arc<dyn MetricsObserver>>Optional per-command observer (SRV-030 extension).
None (the default) keeps today’s behavior exactly: the built-in
counters still record, nothing else runs, and the command label is not
even materialized. Install one when an exporter needs per-command
dimensions or frame-size distributions that cumulative totals cannot
reconstruct — see MetricsObserver.
Implementations§
Source§impl ListenerConfig
impl ListenerConfig
Sourcepub fn new(addr: SocketAddr) -> Self
pub fn new(addr: SocketAddr) -> Self
Config for addr with the defaults: no idle timeout, 1000 ms slow
threshold, credentials enforced, plaintext.
Sourcepub fn with_observer(self, observer: Arc<dyn MetricsObserver>) -> Self
pub fn with_observer(self, observer: Arc<dyn MetricsObserver>) -> Self
Install a per-command metrics observer (SRV-030 extension).
Sourcepub fn with_max_connections(self, max: usize) -> Self
pub fn with_max_connections(self, max: usize) -> Self
Refuse accepts beyond max concurrently open connections (SRV-009
analog for connection count). 0 restores the unbounded default.
Trait Implementations§
Source§impl Clone for ListenerConfig
impl Clone for ListenerConfig
Source§fn clone(&self) -> ListenerConfig
fn clone(&self) -> ListenerConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more