refactor: apply clippy

This commit is contained in:
Edouard Vanbelle
2026-07-27 23:06:02 +02:00
parent 1190dfef87
commit 72b99f5b9a
6 changed files with 28 additions and 30 deletions
+3 -8
View File
@@ -144,10 +144,7 @@ pub(super) async fn dispatch(name: &str, entry: Arc<JobEntry>) -> JobOutcome {
name,
);
advance_next_run(&entry);
return JobOutcome::ok_with(
0,
serde_json::json!({ "skipped": "already_running" }),
);
return JobOutcome::ok_with(0, serde_json::json!({ "skipped": "already_running" }));
}
};
@@ -196,8 +193,7 @@ pub(super) async fn dispatch(name: &str, entry: Arc<JobEntry>) -> JobOutcome {
// by one interval, no backlog queueing.
state.next_run_at = entry.interval.map(|dur| {
Utc::now()
+ chrono::Duration::from_std(dur)
.unwrap_or_else(|_| chrono::Duration::seconds(0))
+ chrono::Duration::from_std(dur).unwrap_or_else(|_| chrono::Duration::seconds(0))
});
}
@@ -217,8 +213,7 @@ fn advance_next_run(entry: &JobEntry) {
let mut state = entry.state.lock().expect("JobState mutex poisoned");
state.next_run_at = entry.interval.map(|dur| {
Utc::now()
+ chrono::Duration::from_std(dur)
.unwrap_or_else(|_| chrono::Duration::seconds(0))
+ chrono::Duration::from_std(dur).unwrap_or_else(|_| chrono::Duration::seconds(0))
});
}
+5 -7
View File
@@ -95,8 +95,7 @@ impl JobRegistry {
}
let next_run_at = interval.map(|dur| {
Utc::now()
+ chrono::Duration::from_std(dur)
.unwrap_or_else(|_| chrono::Duration::seconds(0))
+ chrono::Duration::from_std(dur).unwrap_or_else(|_| chrono::Duration::seconds(0))
});
let entry = Arc::new(JobEntry {
handler,
@@ -186,10 +185,7 @@ impl JobRegistry {
///
/// Works for BOTH scheduled and on-demand jobs — for on-demand
/// jobs this is the only way they ever run.
pub async fn trigger(
self: &Arc<Self>,
name: &str,
) -> Option<JobOutcome> {
pub async fn trigger(self: &Arc<Self>, name: &str) -> Option<JobOutcome> {
let entry = self.get(name).await?;
Some(super::engine::dispatch(name, entry).await)
}
@@ -287,7 +283,9 @@ mod tests {
.await
.unwrap();
// On-demand job — supervisor must never pick it.
reg.register(handler("on_demand"), None, None).await.unwrap();
reg.register(handler("on_demand"), None, None)
.await
.unwrap();
let (next_name, _) = reg.pick_next().await.expect("scheduled job due");
assert_eq!(
+3 -4
View File
@@ -3151,10 +3151,9 @@ impl crate::infrastructure::scheduler::JobHandler for DedupService {
async fn run(&self) -> crate::infrastructure::scheduler::JobOutcome {
use crate::infrastructure::scheduler::JobOutcome;
match self.garbage_collect().await {
Ok((items, bytes)) => JobOutcome::ok_with(
items,
serde_json::json!({ "bytes_reclaimed": bytes }),
),
Ok((items, bytes)) => {
JobOutcome::ok_with(items, serde_json::json!({ "bytes_reclaimed": bytes }))
}
Err(e) => JobOutcome::Err(format!("dedup GC failed: {e}")),
}
}
@@ -122,10 +122,9 @@ impl JobHandler for GrantCleanupService {
/// `Arc<GrantCleanupService>` from the handler.
async fn run(&self) -> JobOutcome {
match self.purge(None).await {
Ok(count) => JobOutcome::ok_with(
count,
serde_json::json!({ "grace_days": self.grace_days }),
),
Ok(count) => {
JobOutcome::ok_with(count, serde_json::json!({ "grace_days": self.grace_days }))
}
Err(e) => JobOutcome::Err(format!("grant cleanup failed: {e}")),
}
}