sdk-go
sdk-go copied to clipboard
Selective `isRetriableFunc` in `cecontext`
This was discussed in https://github.com/knative/eventing/issues/5884 as one solution to make isRetriableFunc and custom status codes configurable on a per request basis via cecontext.WithRetryParams. This is helpful in at least two scenarios:
a) When one does not have control over the (injected) CE client b) When one wants to overwrite retry strategy for status codes on a per request basis, e.g. different endpoints with different status code semantics
Proposal:
Add an IsRetriable field to RetryParams to selectively overwrite what is specified in the underlying CE client protocol implementation. Caveat: this field must be generic, i.e. protocol-independent.
Thoughts?
Sounds good, want to work a PR? There is already precedent for this kind of per-request customizations for the headers.
Happy to work on a PR, though how do we make this protocol-independent? I.e. status codes only make sense for the HTTP protocol implementation.
Alternatively, and this is what you might be referring to, adding this functionality to the http protocol implementation, similar to headers?
Yes exactly!! The headers are in http just because headers in NATs don't make a ton of sense, but there are other context injectables that are selectively used by the protocols defined v2/context. Though it looks like retry is already there. I see what you are saying, we need to add some code in the protocols to support overwriting at request time.
That makes sense! We might need a new context helper method to store and fetch that struct for retry, it looks like it is just a mutation function at the moment.