Struct fregate::Application
source · pub struct Application<'a, H = AlwaysReadyAndAlive, T = Empty> { /* private fields */ }Expand description
Application to set up HTTP server with given config AppConfig
Implementations§
source§impl<'a, T> Application<'a, T>
impl<'a, T> Application<'a, T>
sourcepub fn new(config: &'a AppConfig<T>) -> Application<'a, AlwaysReadyAndAlive, T>
pub fn new(config: &'a AppConfig<T>) -> Application<'a, AlwaysReadyAndAlive, T>
Creates new Application with health checks always returning [200 OK]
source§impl<'a, H, T> Application<'a, H, T>
impl<'a, H, T> Application<'a, H, T>
sourcepub fn health_indicator<Hh: Health>(self, health: Hh) -> Application<'a, Hh, T>
pub fn health_indicator<Hh: Health>(self, health: Hh) -> Application<'a, Hh, T>
Set up new health indicator
sourcepub fn metrics_callback(
self,
metrics_callback: impl Fn() + Send + Sync + 'static
) -> Self
pub fn metrics_callback( self, metrics_callback: impl Fn() + Send + Sync + 'static ) -> Self
Set up callback which will be called before metrics will render.
sourcepub fn use_default_tracing_layer(self, use_default: bool) -> Self
pub fn use_default_tracing_layer(self, use_default: bool) -> Self
Example:
In this case trace_request is not attached to Application so no default tracing/metrics/logging for incoming requests
use fregate::{AppConfig, Application};
#[tokio::main]
async fn main() {
Application::new(&AppConfig::default())
.use_default_tracing_layer(false)
.serve()
.await
.unwrap();
}Trait Implementations§
Auto Trait Implementations§
impl<'a, H = AlwaysReadyAndAlive, T = Empty> !RefUnwindSafe for Application<'a, H, T>
impl<'a, H, T> Send for Application<'a, H, T>where H: Send, T: Sync,
impl<'a, H = AlwaysReadyAndAlive, T = Empty> !Sync for Application<'a, H, T>
impl<'a, H, T> Unpin for Application<'a, H, T>where H: Unpin,
impl<'a, H = AlwaysReadyAndAlive, T = Empty> !UnwindSafe for Application<'a, H, T>
Blanket Implementations§
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request