Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libs/opsqueue_python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion opsqueue/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
11 changes: 9 additions & 2 deletions opsqueue/src/consumer/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
Expand All @@ -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`;
Expand Down
Loading