From: Lukas Wagner <l.wagner@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH datacenter-manager v4 5/6] clippy: remote tasks: implement Default for TaskState
Date: Fri, 6 Feb 2026 14:44:32 +0100 [thread overview]
Message-ID: <20260206134433.311230-8-l.wagner@proxmox.com> (raw)
In-Reply-To: <20260206134433.311230-1-l.wagner@proxmox.com>
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
.../tasks/remote_tasks.rs | 2 +-
server/src/remote_tasks/refresh_task.rs | 24 ++++++++++---------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/server/src/bin/proxmox-datacenter-api/tasks/remote_tasks.rs b/server/src/bin/proxmox-datacenter-api/tasks/remote_tasks.rs
index c5af98b5..1bd94843 100644
--- a/server/src/bin/proxmox-datacenter-api/tasks/remote_tasks.rs
+++ b/server/src/bin/proxmox-datacenter-api/tasks/remote_tasks.rs
@@ -29,7 +29,7 @@ pub fn start_task() -> Result<(), Error> {
/// Task which handles fetching remote tasks and task archive rotation.
/// This function never returns.
async fn remote_task_fetching_task() -> ! {
- let mut task_state = refresh_task::TaskState::new();
+ let mut task_state = refresh_task::TaskState::default();
let mut interval = tokio::time::interval(POLL_INTERVAL);
interval.reset_at(task_utils::next_aligned_instant(POLL_INTERVAL.as_secs()).into());
diff --git a/server/src/remote_tasks/refresh_task.rs b/server/src/remote_tasks/refresh_task.rs
index 820936eb..49cdd112 100644
--- a/server/src/remote_tasks/refresh_task.rs
+++ b/server/src/remote_tasks/refresh_task.rs
@@ -65,17 +65,6 @@ pub struct TaskState {
}
impl TaskState {
- pub fn new() -> Self {
- let now = Instant::now();
-
- Self {
- last_rotate_check: now - CHECK_ROTATE_INTERVAL,
- last_fetch: now - TASK_FETCH_INTERVAL,
- last_journal_apply: now - APPLY_JOURNAL_INTERVAL,
- last_active_poll: now - POLL_ACTIVE_INTERVAL,
- }
- }
-
/// Reset the task archive rotation timestamp.
fn reset_rotate_check(&mut self) {
self.last_rotate_check = Instant::now();
@@ -117,6 +106,19 @@ impl TaskState {
}
}
+impl Default for TaskState {
+ fn default() -> Self {
+ let now = Instant::now();
+
+ Self {
+ last_rotate_check: now - CHECK_ROTATE_INTERVAL,
+ last_fetch: now - TASK_FETCH_INTERVAL,
+ last_journal_apply: now - APPLY_JOURNAL_INTERVAL,
+ last_active_poll: now - POLL_ACTIVE_INTERVAL,
+ }
+ }
+}
+
/// Handle a single timer tick.
/// Will handle archive file rotation, polling of tracked tasks and fetching or remote tasks.
pub async fn handle_timer_tick(task_state: &mut TaskState) -> Result<(), Error> {
--
2.47.3
next prev parent reply other threads:[~2026-02-06 13:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-06 13:44 [PATCH datacenter-manager/proxmox-yew-comp v4 0/8] manual refresh button for remote task cache Lukas Wagner
2026-02-06 13:44 ` [PATCH proxmox-yew-comp v4 1/2] task list: add support for starting refresh tasks Lukas Wagner
2026-02-06 13:44 ` [PATCH proxmox-yew-comp v4 2/2] loadable component: don't trigger reload when starting a task Lukas Wagner
2026-02-06 13:44 ` [PATCH datacenter-manager v4 1/6] remote tasks: move implementation to server crate Lukas Wagner
2026-02-06 13:44 ` [PATCH datacenter-manager v4 2/6] remote tasks: implement `refresh_task_cache` for manual task fetching Lukas Wagner
2026-02-06 13:44 ` [PATCH datacenter-manager v4 3/6] api: add /remotes/tasks/refresh Lukas Wagner
2026-02-06 13:44 ` [PATCH datacenter-manager v4 4/6] ui: remote task view: set refresh_task_url property for task viewer Lukas Wagner
2026-02-06 13:44 ` Lukas Wagner [this message]
2026-02-06 13:44 ` [PATCH datacenter-manager v4 6/6] clippy: remote tasks: remove unneeded enclosing Ok(...) and ? Lukas Wagner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260206134433.311230-8-l.wagner@proxmox.com \
--to=l.wagner@proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.