Skip to content

Commit

Permalink
simplify tracing endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
oxarbitrage committed Jul 23, 2024
1 parent 058788f commit 62a8d71
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions zebrad/src/components/tracing/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ use crate::config::ZebradConfig;
#[cfg(feature = "filter-reload")]
use hyper::{
body::{Body, Incoming},
server::conn::http1,
Method, Request, Response, StatusCode,
};
#[cfg(feature = "filter-reload")]
use hyper_util::{rt::TokioIo, service::TowerToHyperService};
use hyper_util::{
rt::{TokioExecutor, TokioIo},
server::conn::auto::Builder,
};

#[cfg(feature = "filter-reload")]
use crate::{components::tokio::TokioComponent, prelude::*};
Expand Down Expand Up @@ -71,8 +73,9 @@ impl TracingEndpoint {

info!("Trying to open tracing endpoint at {}...", addr);

let svc =
tower::service_fn(|req: Request<Incoming>| async move { request_handler(req).await });
let svc = hyper::service::service_fn(|req: Request<Incoming>| async move {
request_handler(req).await
});

tokio_component
.rt
Expand Down Expand Up @@ -101,8 +104,10 @@ impl TracingEndpoint {
while let Ok((stream, _)) = listener.accept().await {
let io = TokioIo::new(stream);
tokio::spawn(async move {
let svc = TowerToHyperService::new(svc);
if let Err(err) = http1::Builder::new().serve_connection(io, svc).await {
if let Err(err) = Builder::new(TokioExecutor::new())
.serve_connection(io, svc)
.await
{
error!(
"Serve connection in {addr:?} failed: {err:?}.",
addr = addr,
Expand Down

0 comments on commit 62a8d71

Please sign in to comment.