Context-aware methods to ProviderClient and ServiceClient#2883
Context-aware methods to ProviderClient and ServiceClient#2883pierreprinetti merged 1 commit intogophercloud:masterfrom
Conversation
e524823 to
70a81cf
Compare
70a81cf to
a2376c8
Compare
a2376c8 to
87da7b3
Compare
87da7b3 to
693705c
Compare
693705c to
d57a350
Compare
|
This PR has been mentioned in the Gophercloud Slack channel: https://kubernetes.slack.com/archives/C05G4NJ6P6X/p1706708314206099 |
d57a350 to
9854a47
Compare
9854a47 to
4240f51
Compare
|
One last change: Moved the context-merging function to an |
c1cae60 to
1b15d36
Compare
1b15d36 to
b30cdff
Compare
b30cdff to
d91761a
Compare
d91761a to
52ab14b
Compare
52ab14b to
0f1c3c7
Compare
mandre
left a comment
There was a problem hiding this comment.
Thanks @pierreprinetti, I don't think that dropping the values from the second context is a big problem in practice so I'm fine starting with the current implementation and revisit if we find this is a blocking issue. This is already a huge step forward.
provider_client.go
Outdated
|
|
||
| // Context is the context passed to the HTTP request. | ||
| // Context is the context passed to the HTTP request. Values set on the | ||
| // per-call context, when available, override valus set on this |
There was a problem hiding this comment.
Just a nit, feel free to ignore.
| // per-call context, when available, override valus set on this | |
| // per-call context, when available, override values set on this |
internal/ctxt/merge_test.go
Outdated
| t.Run("returns values from both parents", func(t *testing.T) { | ||
| ctx, cancel := ctxt.Merge( | ||
| context.WithValue(context.Background(), "key1", "value1"), | ||
| context.WithValue(context.Background(), "key2", "value2"), |
There was a problem hiding this comment.
Can you perhaps also check that the value from the first context takes precedence when the second context holds the same key? If this is a behavior that we're going to support, then we should have tests for it so that we avoid regressions.
There was a problem hiding this comment.
this is a good idea, thanks
Provide new methods to leverage per-call `context.Context`.
0f1c3c7 to
b49ce37
Compare
Provide new methods to leverage per-call
context.Context.In the http.Request resulting from using these new context-aware calls, the per-call context values take precendence over the ProviderClient's.
Cancellation obeys both the per-call context and the ProviderClient's.