The problem does not occure on the first service

This commit is contained in:
Quentin 2022-06-03 15:41:40 +02:00
parent 0c5cea017b
commit e9c454edaf
Signed by: quentin
GPG Key ID: E9602264D639FF68
1 changed files with 12 additions and 3 deletions

View File

@ -5,12 +5,14 @@ use boitalettres::server::accept::addr::{AddrIncoming, AddrStream};
use boitalettres::server::Server;
use tracing_subscriber;
use tokio::time::{sleep, Duration};
async fn handle_req(req: Request) -> Result<Response> {
use imap_codec::types::response::{Capability, Data};
tracing::debug!("Got request: {:#?}", req);
use tokio::time::{sleep, Duration};
println!("WILL SLEEP");
sleep(Duration::from_millis(100)).await;
println!("DONE SLEEP");
@ -31,10 +33,17 @@ async fn main() -> Result<()> {
let make_service = tower::service_fn(|addr: &AddrStream| {
tracing::debug!(remote_addr = %addr.remote_addr, local_addr = %addr.local_addr, "accept");
async {
let service = tower::ServiceBuilder::new().service_fn(handle_req);
println!("222 WILL SLEEP");
sleep(Duration::from_millis(100)).await;
println!("222 DONE SLEEP");
futures::future::ok::<_, std::convert::Infallible>(service)
let service = tower::ServiceBuilder::new().service_fn(handle_req);
let r: Result<_, boitalettres::errors::Error> = Ok(service);
r
}
});
let server = Server::new(incoming).serve(make_service);