From: "Lukas Wagner" <l.wagner@proxmox.com>
To: "Dominik Csapak" <d.csapak@proxmox.com>,
"Lukas Wagner" <l.wagner@proxmox.com>,
<pdm-devel@lists.proxmox.com>
Subject: Re: [PATCH datacenter-manager v2 16/20] api-cache: add wrapper type
Date: Wed, 26 Aug 2026 14:01:13 +0200 [thread overview]
Message-ID: <DKYUY8B7006X.NYQDJC4X89TU@proxmox.com> (raw)
In-Reply-To: <d549c4ad-f700-463e-8a33-147922228b1a@proxmox.com>
On Mon Aug 24, 2026 at 3:57 PM CEST, Dominik Csapak wrote:
>
>
> On 8/24/26 3:46 PM, Lukas Wagner wrote:
>> On Mon Aug 24, 2026 at 2:33 PM CEST, Dominik Csapak wrote:
>>> i'm missing a bit here why we need a wrapper around a type we fully
>>> control here? couldn't we use NamespacedCache directly?
>>>
>>> what advantage has wrapping it in this way?
>>>
>>> To me it's not immediately obvious, so a short sentence
>>> in the commit message or as comment on the struct, would be good.
>>
>> Sorry, I'll try to add additional justification in the commit message in
>> the next iteration.
>>
>> NamespacedCache is supposed to be fully generic and eventually be moved
>> to a shared crate. ApiCache adds PDM-specific semantics, namely having
>> per-remote namespaces and also one global namespace.
>>
>> Before, these additional semantics were encoded in the helper functions
>> in api_cache.rs (e.g. read_global, read_remote), but since we want to
>> put this thing in PdmApplication, the helpers are turned into methods of
>> this new wrapper type.
>>
>> Hope with this explanation it makes more sense?
>
> yes that makes the patch a bit clearer, thanks for explaining
>
> we could still think about building the namespacing into the
> underlying generic cache struct though,
NamespacedCache is, as the name implies, already namespaced, meaning
that whenever you want to read or write a value, you have to first
provide it the namespace, right now this is done when acquiring the read
or write lock, as the namespace as a whole gets locked.
ApiCache just uses these namespaces to offer semantics better suited to
caching API responses; that is namespaces for individual remotes as well
as a global one for aggregations for results from multiple remotes.
If you do a read_remote(remote: &str), under the hood it will use the
namespace 'remote-{remote}', and read_global just uses a hard-coded
'global' namespace.
Admitted, it adds a bit of boilerplate, but I think it makes it much
more convenient to use for callers.
Anyways, we can still change the approach later, this is just the
smallest change needed to let the API cache be owned by the application
context object.
I've extended the commit message in the upcoming v3 to avoid further
confusion.
Thanks!
>
> e.g we could have a trait
>
> CachePath {
> fn create_cache_path(&self, input: String) -> String
> }
>
> (or similar)
>
> which can be a noop by default, and e.g. pdm can implement a
>
> `NamespacedCache`
>
> that implements it differently
>
>
> then caller can call directly into the cache object and we don't have to
> have a wrapper struct.
>
> not sure if that's practical though ^^
next prev parent reply other threads:[~2026-08-26 12:01 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 14:52 [PATCH datacenter-manager/proxmox v2 00/20] inject application context via API macro for easier integration testing Lukas Wagner
2026-08-20 14:52 ` [PATCH proxmox v2 01/20] router: introduce shared state Lukas Wagner
2026-08-26 13:12 ` Michael Köppl
2026-08-26 13:27 ` Lukas Wagner
2026-08-20 14:52 ` [PATCH proxmox v2 02/20] rest-server: allow to inject " Lukas Wagner
2026-08-20 14:52 ` [PATCH proxmox v2 03/20] api-macro: support shared state extraction type Lukas Wagner
2026-08-24 12:33 ` Dominik Csapak
2026-08-24 13:17 ` Lukas Wagner
2026-08-20 14:52 ` [PATCH datacenter-manager v2 04/20] context: promote context to a dir-style module Lukas Wagner
2026-08-20 14:52 ` [PATCH datacenter-manager v2 05/20] pdm-config: remotes: rename trait methods to read/write/lock Lukas Wagner
2026-08-20 14:52 ` [PATCH datacenter-manager v2 06/20] pdm-config: subscriptions: " Lukas Wagner
2026-08-20 14:52 ` [PATCH datacenter-manager v2 07/20] remote iterator: pass remote config reader explicitly Lukas Wagner
2026-08-20 14:52 ` [PATCH datacenter-manager v2 08/20] context: introduce a ContextFactory to build application context Lukas Wagner
2026-08-24 12:33 ` Dominik Csapak
2026-08-24 13:48 ` Lukas Wagner
2026-08-20 14:52 ` [PATCH datacenter-manager v2 09/20] context: establish PdmApplication object Lukas Wagner
2026-08-21 9:52 ` Thomas Ellmenreich
2026-08-21 12:26 ` Lukas Wagner
2026-08-24 12:33 ` Dominik Csapak
2026-08-24 13:23 ` Lukas Wagner
2026-08-20 14:52 ` [PATCH datacenter-manager v2 10/20] context: register PdmApplication in router Lukas Wagner
2026-08-20 14:52 ` [PATCH datacenter-manager v2 11/20] parallel fetcher: pass arguments to closure in a single type Lukas Wagner
2026-08-20 14:52 ` [PATCH datacenter-manager v2 12/20] parallel fetcher: support a custom client factory Lukas Wagner
2026-08-24 12:33 ` Dominik Csapak
2026-08-24 13:42 ` Lukas Wagner
2026-08-20 14:52 ` [PATCH datacenter-manager v2 13/20] api: sdn: use PdmApplication handle for accessing remotes Lukas Wagner
2026-08-20 14:52 ` [PATCH datacenter-manager v2 14/20] tests: add helpers for building API-handler-level integration tests Lukas Wagner
2026-08-21 9:57 ` Thomas Ellmenreich
2026-08-21 12:25 ` Lukas Wagner
2026-08-20 14:52 ` [PATCH datacenter-manager v2 15/20] tests: add example tests for SDN API routes Lukas Wagner
2026-08-20 14:52 ` [PATCH datacenter-manager v2 16/20] api-cache: add wrapper type Lukas Wagner
2026-08-24 12:33 ` Dominik Csapak
2026-08-24 13:47 ` Lukas Wagner
2026-08-24 13:57 ` Dominik Csapak
2026-08-26 12:01 ` Lukas Wagner [this message]
2026-08-20 14:52 ` [PATCH datacenter-manager v2 17/20] context: provide api-cache on the app object Lukas Wagner
2026-08-20 14:52 ` [PATCH datacenter-manager v2 18/20] api: subscriptions: use PdmApplication instead of globals Lukas Wagner
2026-08-26 14:30 ` Michael Köppl
2026-08-20 14:52 ` [PATCH datacenter-manager v2 19/20] pdm-config: subscriptions: drop unused accessor functions Lukas Wagner
2026-08-20 14:52 ` [PATCH datacenter-manager v2 20/20] tests: add example tests for remote subscription management Lukas Wagner
2026-08-24 12:33 ` [PATCH datacenter-manager/proxmox v2 00/20] inject application context via API macro for easier integration testing Dominik Csapak
2026-08-26 13:49 ` Michael Köppl
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=DKYUY8B7006X.NYQDJC4X89TU@proxmox.com \
--to=l.wagner@proxmox.com \
--cc=d.csapak@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox