pub struct Server { /* private fields */ }Expand description
The Nitr HTTP server: a pool of Lua runtimes behind a shared listener.
Built via Server::builder(); run via serve().
Implementations§
Source§impl Server
impl Server
Sourcepub async fn serve(self) -> Result
pub async fn serve(self) -> Result
Serves until a shutdown signal arrives, then drains gracefully.
The signal contract:
| Signal | Meaning |
|---|---|
SIGTERM | Graceful shutdown (what containers and systemd send) |
SIGINT | Graceful shutdown (ctrl-c) |
SIGHUP | Reload the runtime pool, keeping connections alive |
On Windows only ctrl-c is available; the others are not wired.
Sourcepub async fn serve_with_shutdown(
self,
shutdown: impl Future<Output = ()>,
) -> Result
pub async fn serve_with_shutdown( self, shutdown: impl Future<Output = ()>, ) -> Result
Serves until the given future resolves, then shuts down gracefully: the listener stops accepting and in-flight requests get a grace period to complete.
Source§impl Server
impl Server
Sourcepub fn builder() -> ServerBuilder
pub fn builder() -> ServerBuilder
Creates a ServerBuilder with default configuration.
Sourcepub fn pool(&self) -> Arc<RuntimePool> ⓘ
pub fn pool(&self) -> Arc<RuntimePool> ⓘ
The pool of Lua runtimes currently serving requests.
Sourcepub fn is_ready(&self) -> bool
pub fn is_ready(&self) -> bool
Whether the server is accepting traffic. Cleared at the start of a graceful shutdown, before in-flight requests are drained.
Sourcepub fn cfg_snapshot(&self) -> Option<&Value>
pub fn cfg_snapshot(&self) -> Option<&Value>
The configuration script’s snapshot (nitr.cfg) as of the build;
None without a configuration script.
Sourcepub fn test_client(&self) -> TestClient
pub fn test_client(&self) -> TestClient
An in-process client that dispatches requests through the full
router/middleware/handler path without binding a socket — the
foundation for nitr test and Rust-level integration tests.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Server
impl !UnwindSafe for Server
impl Freeze for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl UnsafeUnpin for Server
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more