Open nightkr opened 1 month ago
One way to detect this would be to add a
const fn is_meta_only() -> bool { false }
to kube::Resource
, implement it as true
for PartialObjectMeta
, and then match on that.
Ah, nice idea. A Resource
level setup for this would let us get rid of / deprecate the whole metadata_watcher
setup as well, since we can then just rely on the opportunism down the stack.
maybe:
/// Resource uses the metadata api
///
/// Forces use of `Request::get_metadata`, `Request::watches_metadata`, `Request::list_metadata`
/// in place of `Request::get`, `Request::watches`, `Request::list`.
const fn metadata_api() -> bool { false }
Would you like to work on this feature?
None
What problem are you trying to solve?
Currently we have two APIs for querying metadata:
Api<K>::get_metadata
(and co)Api<PartialObjectMeta<K>>::get
(and co)Currently, 1 requests that the K8s API only sends the metadata, while 2 requests the whole object and then discards everything else during deserialization. This requires every API to have separate variants to handle metadata-only requests efficiently (and not all of them have that path, like https://docs.rs/kube/latest/kube/runtime/struct.Controller.html#method.watches).
Describe the solution you'd like
Api::get
(and co) should recognize metadata-only types, and automatically switch to the fast path.Describe alternatives you've considered
We could continue threading both variants through all APIs that take an
Api
.Documentation, Adoption, Migration Strategy
This should be transparent for end users: if you use the existing API then things just get more efficient.
Target crate for feature
kube-client