pub struct Server {}
Implementations§
Source§impl Server
impl Server
Sourcepub async fn run<S, F, R>(
registry: R,
addr: S,
shutdown: F,
) -> Result<(), Error>
pub async fn run<S, F, R>( registry: R, addr: S, shutdown: F, ) -> Result<(), Error>
Create and run the metrics Server
§Arguments
registry
- provide theRegistry
you are also registering your metric types to.addr
-host:ip
to tcp listen on.shutdown
- aFuture
, once this completes the server will start to shut down. You can use asignal
orNotify
for clean shutdown orpending
to newer shutdown.
§Result
std::io::Error
is thrown when listening on addr fails. All other causes are handled internally, logged and ignored
§Examples
use prometheus::Registry;
use prometheus_hyper::Server;
use std::{net::SocketAddr, sync::Arc};
let registry = Arc::new(Registry::new());
// Start Server endlessly
tokio::spawn(async move {
Server::run(
Arc::clone(®istry),
SocketAddr::from(([0; 4], 8080)),
futures_util::future::pending(),
)
.await
});
Auto Trait Implementations§
impl Freeze for Server
impl RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl UnwindSafe 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
Mutably borrows from an owned value. Read more