[pdm-devel] [PATCH datacenter-manager v3 1/8] server: task cache: treat a limit of 0 as unbounded
Dominik Csapak
d.csapak at proxmox.com
Mon Aug 25 12:49:54 CEST 2025
On 8/25/25 11:55 AM, Stefan Hanreich wrote:
>
>
> On 8/25/25 10:10 AM, Dominik Csapak wrote:
>> like we do in our other products e.g. like PBS
>> This way, one can specify a way to return *all* tasks.
>>
>> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
>> ---
>> server/src/remote_tasks/mod.rs | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/server/src/remote_tasks/mod.rs b/server/src/remote_tasks/mod.rs
>> index 63a279a..91b79c1 100644
>> --- a/server/src/remote_tasks/mod.rs
>> +++ b/server/src/remote_tasks/mod.rs
>> @@ -36,6 +36,11 @@ pub async fn get_tasks(filters: TaskFilters) -> Result<Vec<TaskListItem>, Error>
>> GetTasks::All
>> };
>>
>> + let limit = match filters.limit {
>> + 0 => usize::MAX,
>> + limit => limit as usize,
>> + };
>> +
>
> is this a usize because of backwards / API compatibility? Otherwise,
> wouldn't an Option be preferrable?
>
i think for the taskfilters it's desireable to have a somehwat sane
default limit in the api (which is currently '50') and make the
'show all tasks' an explicit case, otherwise people rather easily
get all tasks returned, and that can be many
but IMHO this is not set in stone, if we want to return all tasks
by default we could change it of course
since we reuse the `TaskFilters` struct this would also affect the pdm
node tasks themselves.
>> let returned_tasks = cache
>> .get_tasks(which)?
>> .filter_map(|task| {
>> @@ -105,7 +110,7 @@ pub async fn get_tasks(filters: TaskFilters) -> Result<Vec<TaskListItem>, Error>
>> true
>> })
>> .skip(filters.start as usize)
>> - .take(filters.limit as usize)
>> + .take(limit)
>> .collect();
>>
>> Ok(returned_tasks)
>
>
More information about the pdm-devel
mailing list