[pdm-devel] [PATCH proxmox-datacenter-manager 5/8] remote tasks: add background task for task polling, use new task cache
Lukas Wagner
l.wagner at proxmox.com
Fri Apr 11 10:03:19 CEST 2025
On 2025-03-20 18:39, Thomas Lamprecht wrote:
[...]
>>
>> use crate::{api::pve, task_utils};
>>
>> mod task_cache;
>>
>> +const REMOTE_TASKS_DIR: &str = concat!(pdm_buildcfg::PDM_CACHE_DIR_M!(), "/remote-tasks");
>> +
>> +const SECONDS_PER_MINUTE: u64 = 60;
>> +const MINUTES_PER_HOUR: u64 = 60;
> While technically correct this reads like a rate and makes it IMO a bit
> harder to tell what is meant in below calculations.
>
> I'd either use Duration from std, like e.g. Duration::from_mins(10).as_secs()
> and Duration::from_hours(1).as_secs() respectively for REGULAR_REFRESH_S and
> CHECK_ROTATE_S below or just 60 and 3600, those values are pretty much general
> knowledge, which might be a part of the confusion potential I see in your
> variant, as I basically expect that this has to be something more elaborate or
> why would it go for this seemingly complex variant.
> That said, using what the std lib already provides is totally fine here.
>
Finally got the time to incorporate your feedback for a v2.
As it turns out, Duration::from_mins/from_hours is actually
still nightly-only...
https://doc.rust-lang.org/std/time/struct.Duration.html#method.from_mins
Anyway, I'll still change these up a bit; I'll use `Duration` for anything
that is a time interval and then use `Duration::as_secs` for
the cycle calculations. This should make it a bit more idiomatic and
less error-prone.
--
- Lukas
More information about the pdm-devel
mailing list