client: sort out shutdown procedure and harmonize with socks5-client (#2695)

* common/task: rename ShutdownNotifier to TaskManager

* nym-client: return boxed error

* nym-client: enable graceful shutdown

* nym-client: task wait on shutdown to instead exit on closed channel

* Fix build

* Fix unused

* changelog: update
This commit is contained in:
Jon Häggblad
2022-12-14 17:13:00 +01:00
committed by GitHub
parent f6a79ce7c3
commit eb07ec8580
64 changed files with 325 additions and 277 deletions
+5 -5
View File
@@ -9,7 +9,7 @@ use nymsphinx::forwarding::packet::MixPacket;
use std::io;
use tokio::time::Instant;
use super::ShutdownListener;
use super::TaskClient;
// Delay + MixPacket vs Instant + MixPacket
@@ -28,7 +28,7 @@ where
packet_sender: PacketDelayForwardSender,
packet_receiver: PacketDelayForwardReceiver,
node_stats_update_sender: UpdateSender,
shutdown: ShutdownListener,
shutdown: TaskClient,
}
impl<C> DelayForwarder<C>
@@ -38,7 +38,7 @@ where
pub(crate) fn new(
client: C,
node_stats_update_sender: UpdateSender,
shutdown: ShutdownListener,
shutdown: TaskClient,
) -> DelayForwarder<C> {
let (packet_sender, packet_receiver) = mpsc::unbounded();
@@ -134,7 +134,7 @@ mod tests {
use std::sync::{Arc, Mutex};
use std::time::Duration;
use task::ShutdownNotifier;
use task::TaskManager;
use nymsphinx::addressing::nodes::NymNodeRoutingAddress;
use nymsphinx_params::packet_sizes::PacketSize;
@@ -205,7 +205,7 @@ mod tests {
let node_stats_update_sender = UpdateSender::new(stats_sender);
let client = TestClient::default();
let client_packets_sent = client.packets_sent.clone();
let shutdown = ShutdownNotifier::default();
let shutdown = TaskManager::default();
let mut delay_forwarder =
DelayForwarder::new(client, node_stats_update_sender, shutdown.subscribe());
let packet_sender = delay_forwarder.sender();