pub fn spawn(self) -> Server {
        let ready = self.ready.clone();
        let server = self
            .server
            .serve(hyper::service::make_service_fn(move |_conn| {
                let ready = ready.clone();
                future::ok::<_, hyper::Error>(hyper::service::service_fn(
                    move |req: hyper::Request<hyper::Body>| match req.uri().path() {
                        "/live" => future::ok(handle_live(req)),
                        "/ready" => future::ok(handle_ready(&ready, req)),
                        _ => future::ok::<_, hyper::Error>(
                            hyper::Response::builder()
                                .status(hyper::StatusCode::NOT_FOUND)
                                .body(hyper::Body::default())
                                .unwrap(),
                        ),
                    },
                ))
            }));

        let task = tokio::spawn(
            async move {
                debug!("Serving");
                server.await
            }
            .instrument(info_span!("admin", port = %self.addr.port())),
        );

        Server {
            task,
            addr: self.addr,
            ready: self.ready,
        }
    }
/// Binds and runs the server on a background task, returning a handle
Binds and runs the server on a background task, returning a handle
Binds and runs the server on a background task returning a handle
pub fn spawn(self) -> Server {
        let ready = self.ready.clone();
        let server = self
            .server
            .serve(hyper::service::make_service_fn(move |_conn| {
                let ready = ready.clone();
                future::ok::<_, hyper::Error>(hyper::service::service_fn(
                    move |req: hyper::Request<hyper::Body>| match req.uri().path() {
                        "/live" => future::ok(handle_live(req)),
                        "/ready" => future::ok(handle_ready(&ready, req)),
                        _ => future::ok::<_, hyper::Error>(
                            hyper::Response::builder()
                                .status(hyper::StatusCode::NOT_FOUND)
                                .body(hyper::Body::default())
                                .unwrap(),
                        ),
                    },
                ))
            }));
        let task = tokio::spawn(
            async move {
                debug!("Serving");
                server.await
            }
            .instrument(info_span!("admin", port = %self.addr.port())),
        );
        Server {
            task,
            addr: self.addr,
            ready: self.ready,
        }
    }
pub fn spawn ( self ) -> Server { let ready = self . ready . clone ( ) ; let server = self . server . serve ( hyper :: service :: make_service_fn ( move | _conn | { let ready = ready . clone ( ) ; future :: ok :: < _ , hyper :: Error > ( hyper :: service :: service_fn ( move | req : hyper :: Request < hyper :: Body > | match req . uri ( ) . path ( ) { " " => future :: ok ( handle_live ( req ) ) , " " => future :: ok ( handle_ready ( & ready , req ) ) , _ => future :: ok :: < _ , hyper :: Error > ( hyper :: Response :: builder ( ) . status ( hyper :: StatusCode :: NOT_FOUND ) . body ( hyper :: Body :: default ( ) ) . unwrap ( ) , ) , } , ) ) } ) ) ; let task = tokio :: spawn ( async move { debug ! ( " " ) ; server . await } . instrument ( info_span ! ( " " port self addr port ( ) ) ) , ) ; Server { task , addr : self . addr , ready : self . ready , } }
Binds and runs the server on a background task, returning a handle
Binds and runs the server on a background task returning a handle
self
self