-
Notifications
You must be signed in to change notification settings - Fork 69
[WIP] refactor datastore struct #641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
instead added ctx to one function that required it which is more aligned with best practices. Signed-off-by: Nir Rozenbaum <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: nirrozenbaum The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
✅ Deploy Preview for gateway-api-inference-extension ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
The existing logic is intentional. We need the parent context because it is used to start a metrics probing goroutine that should continue to live beyond the life of the reconcile event that triggered its creation. /hold |
can you point me to the code you’re referring to? |
My point is that the context that is created as part of the pod reconcile even is short lived, its lifespan is related to that of the event. The metrics probing thread on the other hand is supposed to live longer than the pod reconcile event that triggered the creation of the metrics probing thread. |
I agree. I was looking to see the specific code you're referring to in order to make sure I'm not missing something.
as far as I know, it's not recommended to store context in a struct. there are other ways in go to do what you're describing here. for example, datastore may use a stop channel and upon receiving a signal on that channel stop all its go routines (that are managed by the datastore struct, each may have a context that can be cancelled or a stop channel). bottom line, best practices recommend not to save context in a struct but to propagate it in function calls. for the use case described above I think stop channel fits more. if the above sounds reasonable to you, I can implement it, LMKWYT. |
Sounds good, @liu-cong perhaps can help review your proposal. |
@nirrozenbaum , yeah a stop channel sounds good to me. The key code path is line #239 in I can review it once you refactor this. Thanks! |
/assign |
+1 sounds great |
PR needs rebase. Instructions 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. |
are we going to use this PR for the restructuring? |
main changed a lot and I'm busy in this cycle with other PRs, will create a new PR probably early next week. |
instead added ctx to one function that required it which is more aligned with best practices.