♻️ Remove Option<>
parent
ec4e0e6335
commit
7d5a491c98
|
@ -50,6 +50,6 @@ async fn main () -> Result <(), Box <dyn Error>> {
|
|||
|
||||
relay::run_relay (
|
||||
Arc::new (RelayState::from (&config_file)),
|
||||
Some (rx)
|
||||
rx
|
||||
).await
|
||||
}
|
||||
|
|
|
@ -27,5 +27,5 @@ async fn main () -> Result <(), Box <dyn Error>> {
|
|||
toml::from_str (&config_s).unwrap_or_else (|_| panic! ("Can't parse {:?} as TOML", config_file_path))
|
||||
};
|
||||
|
||||
ptth::server::main (config_file, None).await
|
||||
ptth::server::run_server (config_file, None).await
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ mod tests {
|
|||
let relay_state_2 = relay_state.clone ();
|
||||
let (stop_relay_tx, stop_relay_rx) = oneshot::channel ();
|
||||
let task_relay = spawn (async move {
|
||||
relay::run_relay (relay_state_2, Some (stop_relay_rx)).await.unwrap ();
|
||||
relay::run_relay (relay_state_2, stop_relay_rx).await.unwrap ();
|
||||
});
|
||||
|
||||
assert! (relay_state.list_servers ().await.is_empty ());
|
||||
|
@ -130,7 +130,7 @@ mod tests {
|
|||
let task_server = {
|
||||
let stop_server_atomic = stop_server_atomic.clone ();
|
||||
spawn (async move {
|
||||
server::main (config_file, Some (stop_server_atomic)).await.unwrap ();
|
||||
server::run_server (config_file, Some (stop_server_atomic)).await.unwrap ();
|
||||
})
|
||||
};
|
||||
|
||||
|
|
|
@ -397,7 +397,7 @@ use tracing::info;
|
|||
|
||||
pub async fn run_relay (
|
||||
state: Arc <RelayState>,
|
||||
shutdown_oneshot: Option <oneshot::Receiver <()>>
|
||||
shutdown_oneshot: oneshot::Receiver <()>
|
||||
)
|
||||
-> Result <(), Box <dyn Error>>
|
||||
{
|
||||
|
@ -433,22 +433,17 @@ pub async fn run_relay (
|
|||
let server = Server::bind (&addr)
|
||||
.serve (make_svc);
|
||||
|
||||
match shutdown_oneshot {
|
||||
Some (rx) => {
|
||||
info! ("Configured for graceful shutdown");
|
||||
server.with_graceful_shutdown (async {
|
||||
rx.await.ok ();
|
||||
|
||||
state.response_rendezvous.clear ();
|
||||
|
||||
let mut request_rendezvoux = state.request_rendezvous.lock ().await;
|
||||
request_rendezvoux.clear ();
|
||||
|
||||
info! ("Received graceful shutdown");
|
||||
}).await?
|
||||
},
|
||||
None => server.await?,
|
||||
};
|
||||
info! ("Configured for graceful shutdown");
|
||||
server.with_graceful_shutdown (async {
|
||||
shutdown_oneshot.await.ok ();
|
||||
|
||||
state.response_rendezvous.clear ();
|
||||
|
||||
let mut request_rendezvoux = state.request_rendezvous.lock ().await;
|
||||
request_rendezvoux.clear ();
|
||||
|
||||
info! ("Received graceful shutdown");
|
||||
}).await?;
|
||||
|
||||
info! ("Exiting");
|
||||
Ok (())
|
||||
|
|
|
@ -124,7 +124,7 @@ use std::sync::atomic::{
|
|||
|
||||
use tracing::info;
|
||||
|
||||
pub async fn main (
|
||||
pub async fn run_server (
|
||||
config_file: ConfigFile,
|
||||
shutdown_atomic: Option <Arc <AtomicBool>>
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue