mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-25 23:15:51 +08:00
refactor(backend): declarative effects (#8128)
* refactor(core): type notice statuses behind the frozen wire contract * refactor(utils): unified retry and strategy-list helpers * refactor(feat): declarative effect registry for verge and clash patches * refactor(core): derive refresh announcements from transaction commit * refactor(core): fold tray, hotkey, autostart updates into effect ensures * refactor(utils): migrate remaining bounded retry loops * docs: add src-tauri architecture guardrails * refactor(core): coalesce burst refresh announcements * refactor(core): complete bounded service retry migration * ci(backend): add architecture ban gates * test(feat): freeze representative effect registry mappings * docs(backend): record dead wire contract entries * chore(core): document watcher exit conditions * fix(backend): preserve applied state across later failures * fix(config): retain runtime after an applied core replacement * refactor(backend): flatten refresh publication and retry policies * docs(backend): focus guardrails on architecture ownership * refactor(effects): use one execution order * fix(config): publish retained runtime and reconcile proxy settings
This commit is contained in:
@@ -130,20 +130,21 @@ impl<E: RunStateEnv> RunStateStore<E> {
|
||||
|
||||
/// Retries transport failures but stops at the first readable reply, including a rejection.
|
||||
pub async fn await_ready(&self, attempts: usize, interval: Duration) -> Result<RunState, ReadyWaitError> {
|
||||
let mut last_error = None;
|
||||
for attempt in 0..attempts {
|
||||
use crate::utils::retry::{RetryError, RetryPolicy, retry};
|
||||
let attempts = std::num::NonZeroUsize::new(attempts).ok_or_else(|| {
|
||||
ReadyWaitError::Unreachable(anyhow::anyhow!(
|
||||
"service readiness wait was configured with no attempts"
|
||||
))
|
||||
})?;
|
||||
retry(RetryPolicy::fixed(attempts, interval), |_| async {
|
||||
match self.env.probe_service_version().await {
|
||||
Ok(reply) => return self.record_reply(&reply).map_err(ReadyWaitError::Rejected),
|
||||
Err(error) => last_error = Some(error),
|
||||
Ok(reply) => self
|
||||
.record_reply(&reply)
|
||||
.map_err(|error| RetryError::Stop(ReadyWaitError::Rejected(error))),
|
||||
Err(error) => Err(RetryError::Retry(ReadyWaitError::Unreachable(error))),
|
||||
}
|
||||
if attempt + 1 < attempts {
|
||||
tokio::time::sleep(interval).await;
|
||||
}
|
||||
}
|
||||
|
||||
Err(ReadyWaitError::Unreachable(last_error.unwrap_or_else(|| {
|
||||
anyhow::anyhow!("service readiness wait was configured with no attempts")
|
||||
})))
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
fn record_reply(&self, reply: &ServiceVersionReply) -> Result<RunState> {
|
||||
|
||||
Reference in New Issue
Block a user