forked from KokaKiwi/boitalettres
The problem does not occure on the first service
This commit is contained in:
parent
0c5cea017b
commit
e9c454edaf
1 changed files with 12 additions and 3 deletions
|
@ -5,12 +5,14 @@ use boitalettres::server::accept::addr::{AddrIncoming, AddrStream};
|
||||||
use boitalettres::server::Server;
|
use boitalettres::server::Server;
|
||||||
use tracing_subscriber;
|
use tracing_subscriber;
|
||||||
|
|
||||||
|
|
||||||
|
use tokio::time::{sleep, Duration};
|
||||||
|
|
||||||
async fn handle_req(req: Request) -> Result<Response> {
|
async fn handle_req(req: Request) -> Result<Response> {
|
||||||
use imap_codec::types::response::{Capability, Data};
|
use imap_codec::types::response::{Capability, Data};
|
||||||
|
|
||||||
tracing::debug!("Got request: {:#?}", req);
|
tracing::debug!("Got request: {:#?}", req);
|
||||||
|
|
||||||
use tokio::time::{sleep, Duration};
|
|
||||||
println!("WILL SLEEP");
|
println!("WILL SLEEP");
|
||||||
sleep(Duration::from_millis(100)).await;
|
sleep(Duration::from_millis(100)).await;
|
||||||
println!("DONE SLEEP");
|
println!("DONE SLEEP");
|
||||||
|
@ -31,10 +33,17 @@ async fn main() -> Result<()> {
|
||||||
|
|
||||||
let make_service = tower::service_fn(|addr: &AddrStream| {
|
let make_service = tower::service_fn(|addr: &AddrStream| {
|
||||||
tracing::debug!(remote_addr = %addr.remote_addr, local_addr = %addr.local_addr, "accept");
|
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);
|
let server = Server::new(incoming).serve(make_service);
|
||||||
|
|
Loading…
Reference in a new issue