refactor(task): move retry primitives into the task crate

This commit is contained in:
Tunglies
2026-11-30 18:48:04 +08:00
parent 03554601a6
commit 75910b8db8
13 changed files with 69 additions and 69 deletions
+1 -1
View File
@@ -237,7 +237,7 @@ impl CoreManager {
anyhow::bail!("core startup blocked after mixed proxy port fallback failure: {reason}");
}
use crate::utils::retry::{RetryError, RetryPolicy, retry};
use clash_verge_task::retry::{RetryError, RetryPolicy, retry};
retry(
RetryPolicy::fixed(
std::num::NonZeroUsize::MIN.saturating_add(MAX_PORT_FALLBACK_RETRIES),
+1 -1
View File
@@ -1,7 +1,6 @@
#[cfg(test)]
use super::claim_core_readiness_generation;
use super::{CoreManager, PROFILE_SELECTIONS_PENDING_COMMIT, RunningMode};
use crate::utils::retry::{RetryError, RetryPolicy, retry};
use crate::{
AsyncHandler,
config::Config,
@@ -11,6 +10,7 @@ use crate::{
};
use anyhow::{Context as _, Result};
use clash_verge_logging::Type;
use clash_verge_task::retry::{RetryError, RetryPolicy, retry};
use futures::{
FutureExt as _,
future::{Map, Shared},
+1 -1
View File
@@ -555,7 +555,7 @@ pub async fn clear() -> Result<()> {
/// A failed system call is usually a transient RPC hiccup, so give it a few tries.
async fn clear_with_retry() -> Result<()> {
use crate::utils::retry::{RetryError, RetryPolicy, retry};
use clash_verge_task::retry::{RetryError, RetryPolicy, retry};
retry(
RetryPolicy::fixed(
std::num::NonZeroUsize::MIN.saturating_add((CLEAR_ATTEMPTS - 1) as usize),
+1 -1
View File
@@ -135,7 +135,7 @@ 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> {
use crate::utils::retry::{RetryError, RetryPolicy, retry};
use clash_verge_task::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"
+2 -2
View File
@@ -1302,7 +1302,7 @@ async fn create_sync_temp(target: &Path) -> Result<(PathBuf, tokio::fs::File)> {
.with_context(|| format!("failed to create provider cache directory {}", parent.display()))?;
}
let name = target.file_name().map_or_default(|name| name.to_string_lossy());
use crate::utils::retry::{RetryError, RetryPolicy, retry};
use clash_verge_task::retry::{RetryError, RetryPolicy, retry};
retry(
RetryPolicy::fixed(std::num::NonZeroUsize::MIN.saturating_add(7), std::time::Duration::ZERO),
|_| async {
@@ -1719,7 +1719,7 @@ async fn recover_after_owner_loss_while_locked(reason: OwnerRecoveryReason) {
}
async fn clear_proxy_after_owner_loss() {
use crate::utils::retry::{RetryError, RetryPolicy, retry};
use clash_verge_task::retry::{RetryError, RetryPolicy, retry};
let result = retry(
RetryPolicy::fixed(
std::num::NonZeroUsize::MIN.saturating_add(2),