From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 2D4241FF13E for ; Fri, 06 Feb 2026 14:44:42 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4992A3CA4; Fri, 6 Feb 2026 14:45:14 +0100 (CET) From: Lukas Wagner 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 Message-ID: <20260206134433.311230-8-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260206134433.311230-1-l.wagner@proxmox.com> References: <20260206134433.311230-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1770385398472 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.038 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 2AKXZHYY5XQWG22OD2NW2Q7WH4JOU2T7 X-Message-ID-Hash: 2AKXZHYY5XQWG22OD2NW2Q7WH4JOU2T7 X-MailFrom: l.wagner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Lukas Wagner --- .../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