Skip to content

Commit

Permalink
Use BoxFuture helper
Browse files Browse the repository at this point in the history
  • Loading branch information
RReverser committed Sep 9, 2024
1 parent 6852d00 commit 8587fc6
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ use axum::extract::{FromRequest, Path, Request};
use axum::response::IntoResponse;
use axum::routing::MethodFilter;
use axum::Router;
use futures::future::{BoxFuture, Future, FutureExt};
use net_literals::addr;
use sailfish::TemplateOnce;
use std::collections::BTreeMap;
use std::future::Future;
use std::net::SocketAddr;
use std::pin::Pin;
use std::sync::Arc;
use tracing::Instrument;

Expand Down Expand Up @@ -113,7 +112,7 @@ impl ServerHandler {
pub struct BoundServer {
// Axum types are a bit complicated, so just Box it for now.
#[debug(skip)]
axum: Pin<Box<dyn Future<Output = eyre::Result<std::convert::Infallible>> + Send>>,
axum: BoxFuture<'static, eyre::Result<std::convert::Infallible>>,
axum_listen_addr: SocketAddr,
discovery: BoundDiscoveryServer,
}
Expand Down Expand Up @@ -185,19 +184,18 @@ impl Server {
tracing::debug!("Bound Alpaca discovery server");

Ok(BoundServer {
axum: Box::pin(
async move {
axum::serve(
listener,
self.into_router()
// .layer(TraceLayer::new_for_http())
.into_make_service(),
)
.await?;
unreachable!("Alpaca server should never stop without an error")
}
.instrument(tracing::error_span!("alpaca_server_loop")),
),
axum: async move {
axum::serve(
listener,
self.into_router()
// .layer(TraceLayer::new_for_http())
.into_make_service(),
)
.await?;
unreachable!("Alpaca server should never stop without an error")
}
.instrument(tracing::error_span!("alpaca_server_loop"))
.boxed(),
axum_listen_addr: bound_addr,
discovery: discovery_server,
})
Expand Down

0 comments on commit 8587fc6

Please sign in to comment.