pub struct ApplicationServer;Expand description
Application server struct.
This struct contains the methods for starting and stopping the server, as well as handling errors and metrics.
Struct has no fields, as all the methods are static and storing the services is handled by Axum.
Implementations§
source§impl ApplicationServer
impl ApplicationServer
const HTTP_TIMEOUT: u64 = 60u64
sourcepub async fn serve(
config: DarkwingConfig,
db: Database,
cache: Cache,
) -> Result<()>
pub async fn serve( config: DarkwingConfig, db: Database, cache: Cache, ) -> Result<()>
Starts the server with the given configuration, database, and cache.
sourceasync fn handle_timeout_error(err: BoxError) -> (StatusCode, Json<Value>)
async fn handle_timeout_error(err: BoxError) -> (StatusCode, Json<Value>)
Adds a custom handler for tower’s TimeoutLayer, see https://docs.rs/axum/latest/axum/middleware/index.html#commonly-used-middleware.
sourceasync fn track_metrics(request: Request<Body>, next: Next) -> impl IntoResponse
async fn track_metrics(request: Request<Body>, next: Next) -> impl IntoResponse
Tracks the metrics for the request, i.e. latency, status code, etc.
Saves the metrics to the Prometheus.
sourceasync fn shutdown_signal()
async fn shutdown_signal()
Tokio signal handler that will wait for a user to press CTRL+C.
We use this in our hyper Server method with_graceful_shutdown.
async fn handle_404() -> impl IntoResponse
Auto Trait Implementations§
impl Freeze for ApplicationServer
impl RefUnwindSafe for ApplicationServer
impl Send for ApplicationServer
impl Sync for ApplicationServer
impl Unpin for ApplicationServer
impl UnwindSafe for ApplicationServer
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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 moreCreates a shared type from an unshared type.
§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.