Datalayer refactoring: HTTP datasource and client#2120
Datalayer refactoring: HTTP datasource and client#2120k8s-ci-robot merged 4 commits intokubernetes-sigs:mainfrom
Conversation
Signed-off-by: irar2 <irar@il.ibm.com>
✅ Deploy Preview for gateway-api-inference-extension ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Hi @irar2. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
pkg/epp/datalayer/http/client.go
Outdated
| @@ -1,5 +1,5 @@ | |||
| /* | |||
| Copyright 2025 The Kubernetes Authors. | |||
| Copyright 2026 The Kubernetes Authors. | |||
There was a problem hiding this comment.
nit: the copyright is realy 2025-... I don't think we need to change copyright statements in files modified in a specific year,
|
|
||
| client Client // client (e.g. a wrapped http.Client) used to get metrics | ||
| client Client // client (e.g. a wrapped http.Client) used to get data | ||
| parser func(io.Reader) (any, error) |
There was a problem hiding this comment.
Q: I think there are two high level ways to refactor this:
- keep a shared implementation and configure it from the outside with implementation specific details (the typed-name, parse callback, output type, etc); or
- create specific instances (e.g., metrics, v1/models) that build a data source from lower level building blocks (e.g., they would have their own TypedName, call client.Get() and then pass the result to an internal parse method, instead of adding parse to the Get parameters).
To clarify, you could still have an HTTPDataSource under pkg/epp/datalayer/http, but add MetricsSource and ModelsSource Go files next to it or in their own directories. By embedding an HTTPDataSource the specific sources could reuse the shared implementation.
Out of curiosuity, any thoughts on preferring one over the other? Either approach works, they can be thought of as composition vs inheritance.
I would lean towards the second approach (e.g., there is no HTTPDataSource registered factory in the system, only ones for metrics and v1/models so the HTTP bits seem like an implemntation detail to me and can be modeled as function "building blocks" and not reuse the full struct, esp. since v1/models would be in a different repo altogether).
There was a problem hiding this comment.
I think that the second approach allows less code reuse comparing to the first one
|
/ok-to-test |
Signed-off-by: irar2 <irar@il.ibm.com>
Signed-off-by: irar2 <irar@il.ibm.com>
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: irar2, nirrozenbaum The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PR refactors metrics datasource and client into a general HTTP datasource and client, allowing code reuse in similar scenarios, e.g., gathering of models info.
Which issue(s) this PR fixes:
Does this PR introduce a user-facing change?: