feat(runstate): retry service version probing

This commit is contained in:
oomeow
2026-08-01 17:01:39 +08:00
parent 8ef6f0cc23
commit cf29b714d3
+23 -3
View File
@@ -24,8 +24,9 @@ use std::{
time::Duration,
};
use anyhow::{Context as _, Result, bail};
use anyhow::{Context as _, Error, Result, bail};
use arc_swap::ArcSwap;
use backon::{ConstantBuilder, Retryable as _};
use clash_verge_logging::{Type, logging};
use once_cell::sync::Lazy;
use parking_lot::Mutex;
@@ -221,8 +222,27 @@ impl<E: RunStateEnv> RunStateStore<E> {
return classify_service_health(CurrentServiceProbe::Missing, false, "");
}
match self.env.probe_service_version().await {
Ok(reply) => classify_service_health(probe_outcome(&reply), has_marker, ""),
let result = (|| async {
let reply = self.env.probe_service_version().await?;
let service_health = classify_service_health(probe_outcome(&reply), has_marker, "");
anyhow::Ok(service_health)
})
.retry(
ConstantBuilder::default()
.with_delay(Duration::from_millis(500))
.with_max_times(10),
)
.notify(|err, dur| {
logging!(
warn,
Type::Service,
"get service version failed: {err}, retrying in {dur:?}"
);
})
.await;
match result {
Ok(service_health) => service_health,
Err(error) => {
logging!(warn, Type::Service, "current service IPC is unavailable: {error:#}");
classify_service_health(