pub struct Server { /* private fields */ }Expand description
Everything the HTTP layer serves from.
Built by Server::start, shared behind an Arc by the router, and
immutable afterwards: sections are established at startup and the set
does not change while the process runs. Adding one is a restart, which is
the same answer the rest of this workspace gives to “where do the sources
live”.
Implementations§
Source§impl Server
impl Server
Sourcepub fn start(config: &ServerConfig) -> Result<Self, StartupError>
pub fn start(config: &ServerConfig) -> Result<Self, StartupError>
Loads every section and refuses to start if anything is wrong.
The order matters: ServerConfig::validate runs first and nothing
is opened if it refuses, so a server that would have been
world-readable never gets as far as reading a secret off disk.
A section that will not load at startup is fatal. A config server that comes up serving nothing for one application is a silent outage for whoever needed it — better to fail the deployment.
§Errors
A Refusal, a section that will not load, or a watch that will not
start.
Sourcepub fn start_with(
config: &ServerConfig,
audit: impl AuditSink,
) -> Result<Self, StartupError>
pub fn start_with( config: &ServerConfig, audit: impl AuditSink, ) -> Result<Self, StartupError>
Sourcepub fn address(&self) -> SocketAddr
pub fn address(&self) -> SocketAddr
The address the binary listens on.
Sourcepub fn tls(&self) -> Option<&Tls>
Available on crate feature tls only.
pub fn tls(&self) -> Option<&Tls>
tls only.The loaded TLS configuration, or None for a server that expects a
terminator in front of it.
What serve_tls needs, and what tells an
embedder which of the two serving paths to take.
Sourcepub fn authenticate(&self, authorization: Option<&str>) -> Option<Principal>
pub fn authenticate(&self, authorization: Option<&str>) -> Option<Principal>
Who is calling, given the raw Authorization header.
Sourcepub fn section(&self, application: &str, profile: &str) -> Option<&Arc<Section>>
pub fn section(&self, application: &str, profile: &str) -> Option<&Arc<Section>>
The section serving application at profile, if one does.
Call this only after authorising. It is the lookup that would otherwise tell a caller whether a section exists, and the whole not-an-oracle property rests on nothing reaching it that has not already been granted the application.
Sourcepub fn record(&self, entry: &AuditEntry)
pub fn record(&self, entry: &AuditEntry)
Records one request.
Sourcepub fn streams_enabled(&self) -> bool
pub fn streams_enabled(&self) -> bool
Whether this server serves change streams at all.
Sourcepub fn open_stream(&self) -> Option<StreamPermit>
pub fn open_stream(&self) -> Option<StreamPermit>
A place in the change-stream ceiling, if there is one free.
A compare-and-swap loop rather than a fetch-add and a refund: an increment that overshoots is briefly visible to another request, which would let two callers each see the ceiling exceeded and both back off.
Sourcepub fn open_streams(&self) -> usize
pub fn open_streams(&self) -> usize
How many change streams are open. For the tests and for a deployment that wants the number in its own metrics.
Source§impl Server
impl Server
Sourcepub fn posture(&self) -> &'static str
Available on crate feature tls only.
pub fn posture(&self) -> &'static str
tls only.How this server’s own socket is protected, in a few words — for a
startup line, a Debug and an operator’s first question.
One of none, tls or tls, client certificate required. Never a
path, never a subject, never a key: it says which of the three shapes
this process is in and nothing about the material it is in it with.