pub struct EmbeddedServer { /* private fields */ }Expand description
A running liminal server with no listener, granting in-process connections.
Built from the same ingredients the production stack is built from — services, an optional connection auth token, and the operational limits — and torn down on drop, so an embedded server’s lifetime is its handle’s.
Implementations§
Source§impl EmbeddedServer
impl EmbeddedServer
Sourcepub fn with_services(
services: Arc<dyn ConnectionServices>,
) -> Result<Self, ServerError>
pub fn with_services( services: Arc<dyn ConnectionServices>, ) -> Result<Self, ServerError>
Starts an embedded server over services, open-access and at the
default limits.
§Errors
Returns ServerError when incarnation startup or scheduler startup
fails.
Sourcepub fn with_services_auth_and_limits(
services: Arc<dyn ConnectionServices>,
auth_token: Option<Vec<u8>>,
limits: LimitsConfig,
) -> Result<Self, ServerError>
pub fn with_services_auth_and_limits( services: Arc<dyn ConnectionServices>, auth_token: Option<Vec<u8>>, limits: LimitsConfig, ) -> Result<Self, ServerError>
Starts an embedded server over services, gated by auth_token when
one is configured, under limits.
The three arguments are exactly the three
ConnectionSupervisor::with_services_auth_and_limits takes, because
an embedded server is a production stack with the listener removed and
nothing else: None for the token is the open-access server an absent
[auth] section produces, and limits carries the same
max_connections bound that both connection admission and the durable
incarnation stream enforce.
§Errors
Returns ServerError when incarnation startup or scheduler startup
fails.
Sourcepub fn connect_loopback(&self) -> Result<LoopbackClientEnd, ServerError>
pub fn connect_loopback(&self) -> Result<LoopbackClientEnd, ServerError>
Admits one in-process connection and returns the caller’s end of it.
This is the whole grant. It replaces exactly the listener’s accept() +
spawn_connection pair and nothing else about admission: the returned
end is a byte stream that has not yet handshaken, so the caller still
sends Connect and still receives ConnectAck or ConnectError from
the same connect_response a socket client reaches.
Dropping the returned end tears the connection down by the same end-of-file a socket hangup produces, releasing its admission slot.
§Errors
Returns ServerError::ConnectionLimitReached when the server is at
its max_connections bound — the identical typed refusal a socket
connect receives at capacity, surfaced as an error rather than a panic —
and other ServerError values when incarnation allocation or process
spawn fails. On every refusal the duplex is dropped whole, so no half of
a rejected connection survives.
Trait Implementations§
Source§impl Debug for EmbeddedServer
impl Debug for EmbeddedServer
Source§impl Drop for EmbeddedServer
impl Drop for EmbeddedServer
Source§fn drop(&mut self)
fn drop(&mut self)
Stops the connection scheduler, mirroring the in-tree socket fixtures’
teardown (SdkSocketFixture::stop): every host record is removed while
the readiness owner is still live, then the scheduler is shut down.
Teardown is Drop alone rather than a shutdown method plus Drop
because Rust drop points are already deterministic — a caller that wants
the server stopped at a particular moment drops it at that moment — and
a second spelling of the same act is a second surface to keep honest.