[pdm-devel] [PATCH datacenter-manager v2] ui: resource tree: use AsyncAbortGuard to cancel obsolete pending loads

Dominik Csapak d.csapak at proxmox.com
Wed Apr 23 08:49:47 CEST 2025


On 4/22/25 22:13, Thomas Lamprecht wrote:
> Am 18.04.25 um 09:46 schrieb Dominik Csapak:
>> Currently, if a new serach term is given, a new load will occur if the
>> INPUT_BUFFER_MS time is reached. Any old in-flight API requests are not
>> canceled, and might still arrive.
>>
>> To prevent that, use an AsyncAbortGuard so the old load will be aborted
>> whenever it is overwritten.
>>
>> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
>> ---
>> changes from v1:
>> * use AsyncAbortGuard instead of AsyncPool, since that's the correct
>>    abstraction here.
>> * introduce a new Msg variant, so that we can overwrite the AsyncAbortGuard
>>    in the update method
>>
>> replaces:
>> https://lore.proxmox.com/pdm-devel/20250416113232.2488103-1-d.csapak@proxmox.com/
> 
> Yeah, this reads a bit nicer and more convenient.
>   
>>   ui/src/widget/resource_tree.rs | 28 +++++++++++++++++++---------
>>   1 file changed, 19 insertions(+), 9 deletions(-)
>>
> 
>> @@ -88,6 +89,7 @@ async fn load_resources(search_term: String) -> Result<Vec<RemoteResources>, Err
>>   }
>>   
>>   pub enum Msg {
>> +    LoadRequest,
> 
> Tiny nit: would it be a tiny bit more and telling and consistent with pwt if we
> would name this message "UpdateFilter"? E.g. like PwtSearchDropdown uses.
> 
> Could be adapted on applying though.

yes that makes sense. Would be great if you could adapt that on applying
if there is nothing else to change

> 
>>       Load,
>>       LoadResult(Result<Vec<RemoteResources>, Error>),
>>       RemoteListChanged(RemoteList),
> 
> 
> 




More information about the pdm-devel mailing list