Skip to content
Closed
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
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