diff --git a/crates/common/src/shutdown.rs b/crates/common/src/shutdown.rs index 1e616cd1..c80e4c6b 100644 --- a/crates/common/src/shutdown.rs +++ b/crates/common/src/shutdown.rs @@ -5,22 +5,26 @@ use std::sync::Arc; pub struct ShutdownSignal { shutdown_tx: Option>, instance_name: String, + generation_id: u64, } #[derive(Clone, Debug)] pub struct ShutdownMessage { pub error: Arc, pub instance_name: String, + pub generation_id: u64, } impl ShutdownSignal { pub fn new( shutdown_tx: async_broadcast::Sender, instance_name: String, + generation_id: u64, ) -> Self { Self { shutdown_tx: Some(shutdown_tx), instance_name, + generation_id, } } @@ -29,6 +33,7 @@ impl ShutdownSignal { _ = shutdown_tx.try_broadcast(ShutdownMessage { error: Arc::new(fatal_error), instance_name: self.instance_name.clone(), + generation_id: self.generation_id, }); } else { // We don't anyone to shutdown signal configured. Just panic. @@ -41,6 +46,7 @@ impl ShutdownSignal { Self { shutdown_tx: None, instance_name: "".to_owned(), + generation_id: 0, } } @@ -50,6 +56,7 @@ impl ShutdownSignal { Self { shutdown_tx: Some(sender), instance_name: "".to_owned(), + generation_id: 0, } } } diff --git a/crates/local_backend/src/main.rs b/crates/local_backend/src/main.rs index 4ac49a21..b0c989b0 100644 --- a/crates/local_backend/src/main.rs +++ b/crates/local_backend/src/main.rs @@ -100,7 +100,7 @@ async fn run_server(runtime: ProdRuntime, config: LocalConfig) -> anyhow::Result async fn run_server_inner(runtime: ProdRuntime, config: LocalConfig) -> anyhow::Result<()> { // Used to receive fatal errors from the database or /preempt endpoint. let (preempt_tx, mut preempt_rx) = async_broadcast::broadcast(1); - let preempt_signal = ShutdownSignal::new(preempt_tx.clone(), config.name()); + let preempt_signal = ShutdownSignal::new(preempt_tx.clone(), config.name(), 0); // Use to signal to the http service to stop. let (shutdown_tx, shutdown_rx) = async_broadcast::broadcast(1); let persistence = connect_persistence( diff --git a/crates/local_backend/src/test_helpers.rs b/crates/local_backend/src/test_helpers.rs index 887bb190..ab8a269a 100644 --- a/crates/local_backend/src/test_helpers.rs +++ b/crates/local_backend/src/test_helpers.rs @@ -72,7 +72,7 @@ pub async fn setup_backend_for_test(runtime: ProdRuntime) -> anyhow::Result