diff --git a/src/grpc_subscription_autoreconnect_tasks.rs b/src/grpc_subscription_autoreconnect_tasks.rs index c5727d4..f15741c 100644 --- a/src/grpc_subscription_autoreconnect_tasks.rs +++ b/src/grpc_subscription_autoreconnect_tasks.rs @@ -6,6 +6,7 @@ use std::time::Duration; use tokio::sync::mpsc::error::SendTimeoutError; use tokio::sync::mpsc::Receiver; use tokio::sync::broadcast; +use tokio::sync::broadcast::error::RecvError; use tokio::task::JoinHandle; use tokio::time::{sleep, timeout, Instant}; use yellowstone_grpc_client::{GeyserGrpcClient, GeyserGrpcClientError}; @@ -379,16 +380,27 @@ enum MaybeExit { Exit, } -async fn await_or_exit(future: F, exit_notify: E) -> MaybeExit +async fn await_or_exit(future: F, exit_notify: E) -> MaybeExit where F: Future, - E: Future, + E: Future>, { tokio::select! { res = future => { MaybeExit::Continue(res) }, - _ = exit_notify => { + res = exit_notify => { + match res { + Ok(_) => { + debug!("exit on signal"); + } + Err(RecvError::Lagged(_)) => { + warn!("exit on signal (lag)"); + } + Err(RecvError::Closed) => { + warn!("exit on signal (channel close)"); + } + } MaybeExit::Exit } }