Skip to main content

Server

Struct Server 

Source
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

Source

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.

Source

pub fn start_with( config: &ServerConfig, audit: impl AuditSink, ) -> Result<Self, StartupError>

start, with somewhere else for the audit log to go.

§Errors

As start.

Source

pub fn address(&self) -> SocketAddr

The address the binary listens on.

Source

pub fn tls(&self) -> Option<&Tls>

Available on crate feature 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.

Source

pub fn authenticate(&self, authorization: Option<&str>) -> Option<Principal>

Who is calling, given the raw Authorization header.

Source

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.

Source

pub fn sections(&self) -> impl Iterator<Item = &Arc<Section>>

Every served section.

Source

pub fn is_ready(&self) -> bool

Whether every section is ready. What /readyz answers.

Source

pub fn record(&self, entry: &AuditEntry)

Records one request.

Source

pub fn streams_enabled(&self) -> bool

Whether this server serves change streams at all.

Source

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.

Source

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

Source

pub fn posture(&self) -> &'static str

Available on crate feature 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.

Trait Implementations§

Source§

impl Debug for Server

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Server

§

impl !RefUnwindSafe for Server

§

impl !UnwindSafe for Server

§

impl Send for Server

§

impl Sync for Server

§

impl Unpin for Server

§

impl UnsafeUnpin for Server

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.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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.