pub struct ServerBuilder {}Implementations§
Source§impl ServerBuilder
impl ServerBuilder
Sourcepub async fn serve(
addr: SocketAddr,
registry: Option<Registry>,
cancellation_token: CancellationToken,
) -> Result<WithGracefulShutdown<IntoMakeService<Router>, Router, impl Future<Output = ()>>, Error>
pub async fn serve( addr: SocketAddr, registry: Option<Registry>, cancellation_token: CancellationToken, ) -> Result<WithGracefulShutdown<IntoMakeService<Router>, Router, impl Future<Output = ()>>, Error>
Function that builds a new Metrics server and returns a
WithGracefulShutdown instance ready to be spawn.
The available methods are:
builder: Creates a new builder instance.addr: Sets theSocketAddrto bind the metrics server to.registry: Sets theRegistryto use for metrics. (optional)build: Builds the metrics server and returns aWithGracefulShutdowninstance.
§Examples
async fn build_metrics() -> Result<(), Error> {
ServerBuilder::builder()
.addr("127.0.0.1".parse::<SocketAddr>().unwrap())
.cancellation_token(CancellationToken::new())
.build()
.await?;
Ok(())
}§Panics
Panics on failure of the gather_metrics internal methods (unlikely)
§Errors
This function will return an error if the provided addr is invalid
Source§impl ServerBuilder
impl ServerBuilder
Sourcepub fn builder() -> ServeServerBuilderBuilder
pub fn builder() -> ServeServerBuilderBuilder
Function that builds a new Metrics server and returns a
WithGracefulShutdown instance ready to be spawn.
The available methods are:
builder: Creates a new builder instance.addr: Sets theSocketAddrto bind the metrics server to.registry: Sets theRegistryto use for metrics. (optional)build: Builds the metrics server and returns aWithGracefulShutdowninstance.
§Examples
async fn build_metrics() -> Result<(), Error> {
ServerBuilder::builder()
.addr("127.0.0.1".parse::<SocketAddr>().unwrap())
.cancellation_token(CancellationToken::new())
.build()
.await?;
Ok(())
}§Panics
Panics on failure of the gather_metrics internal methods (unlikely)
§Errors
This function will return an error if the provided addr is invalid
Auto Trait Implementations§
impl Freeze for ServerBuilder
impl RefUnwindSafe for ServerBuilder
impl Send for ServerBuilder
impl Sync for ServerBuilder
impl Unpin for ServerBuilder
impl UnsafeUnpin for ServerBuilder
impl UnwindSafe for ServerBuilder
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
Mutably borrows from an owned value. Read more