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
+2 -2
View File
@@ -12,7 +12,7 @@ use nym_api_requests::models::{MixNodeBondAnnotated, MixnodeStatus};
use rocket::fairing::AdHoc;
use std::collections::HashMap;
use std::{sync::Arc, time::Duration};
use task::ShutdownListener;
use task::TaskClient;
use tokio::sync::RwLockReadGuard;
use tokio::{
sync::{watch, RwLock},
@@ -174,7 +174,7 @@ impl NodeStatusCacheRefresher {
}
}
pub async fn run(&mut self, mut shutdown: ShutdownListener) {
pub async fn run(&mut self, mut shutdown: TaskClient) {
let mut fallback_interval = time::interval(self.fallback_caching_interval);
while !shutdown.is_shutdown() {
tokio::select! {
@@ -8,7 +8,7 @@ use crate::node_status_api::ONE_DAY;
use crate::storage::NymApiStorage;
use log::error;
use std::time::Duration;
use task::ShutdownListener;
use task::TaskClient;
use time::{OffsetDateTime, PrimitiveDateTime, Time};
use tokio::time::{interval, sleep};
@@ -68,7 +68,7 @@ impl HistoricalUptimeUpdater {
Ok(())
}
pub(crate) async fn run(&self, mut shutdown: ShutdownListener) {
pub(crate) async fn run(&self, mut shutdown: TaskClient) {
// update uptimes at 23:00 UTC each day so that we'd have data from the actual [almost] whole day
// and so that we would avoid the edge case of starting validator API at 23:59 and having some
// nodes update for different days