From bd0a42e7f45ccd2750071e3dd3cd9bd4dda4fd25 Mon Sep 17 00:00:00 2001 From: Marten Wijnja Date: Tue, 23 Sep 2025 12:53:40 +0200 Subject: [PATCH 1/2] Add `.is_healthy()` method to the Opsqueue Consumer client --- opsqueue/src/consumer/client.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/opsqueue/src/consumer/client.rs b/opsqueue/src/consumer/client.rs index 35e66ec..27c554f 100644 --- a/opsqueue/src/consumer/client.rs +++ b/opsqueue/src/consumer/client.rs @@ -123,8 +123,7 @@ impl OuterClient { } async fn ensure_initialized(&self) { - let inner = self.0.load(); - if inner.is_none() || inner.as_ref().is_some_and(|c| !c.is_healthy()) { + if !self.is_healthy() { let client = self.initialize().await; self.0.store(Some(Arc::new(client))); } @@ -138,6 +137,14 @@ impl OuterClient { .await .expect("Infinite retries should never return Err") } + + /// When `false` is returned, the next call to the client will attempt to restore the connection. + /// + /// This function can be used to propagate healthiness info to a consumer service. + pub fn is_healthy(&self) -> bool { + let inner = self.0.load(); + inner.as_ref().is_some_and(|c| c.is_healthy()) + } } // TOOD: Set max retries to `None`; From f258a6683d37d726567fde20d52f8443c599500a Mon Sep 17 00:00:00 2001 From: Marten Wijnja Date: Wed, 3 Dec 2025 12:28:45 +0100 Subject: [PATCH 2/2] Bump version: 0.32.0 --- Cargo.lock | 4 ++-- libs/opsqueue_python/Cargo.toml | 2 +- opsqueue/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 36000dd..46731c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1972,7 +1972,7 @@ dependencies = [ [[package]] name = "opsqueue" -version = "0.31.0" +version = "0.32.0" dependencies = [ "anyhow", "arc-swap", @@ -2026,7 +2026,7 @@ dependencies = [ [[package]] name = "opsqueue_python" -version = "0.31.0" +version = "0.32.0" dependencies = [ "anyhow", "chrono", diff --git a/libs/opsqueue_python/Cargo.toml b/libs/opsqueue_python/Cargo.toml index bf32aff..db21f22 100644 --- a/libs/opsqueue_python/Cargo.toml +++ b/libs/opsqueue_python/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "opsqueue_python" -version = "0.31.0" +version = "0.32.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/opsqueue/Cargo.toml b/opsqueue/Cargo.toml index 185b0bc..f89647c 100644 --- a/opsqueue/Cargo.toml +++ b/opsqueue/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "opsqueue" -version = "0.31.0" +version = "0.32.0" edition = "2021" description = "lightweight batch processing queue for heavy loads" repository = "https://github.com/channable/opsqueue"