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 theRegistryyou are also registering your metric types to.addr-host:ipto tcp listen on.shutdown- aFuture, once this completes the server will start to shut down. You can use asignalorNotifyfor clean shutdown orpendingto newer shutdown.
§Result
std::io::Erroris 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 UnsafeUnpin 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