go-grpc-middleware
go-grpc-middleware copied to clipboard
FR: retry should pass the grpc.Status from err to BackoffFuncContext
Retry interceptor (and possibly others) should pass status.Convert(err)
to the client-supplied callback function, i.e. BackoffFuncContext()
. Grpc services often return information in Status.Details
which may affect the decision as to how long to wait until the next retry.
Currently the API does not supply the error returned from invocation to the callback function, so there is no way for the callback function to inspect the error and Status.
Could you give an example of how you'd like to see this work? Maybe a use case?
A use case is the OpenTelemetry Collector protocol, which specifies that clients should throttle themselves based on the status returned from a failed GRPC call.
See https://github.com/open-telemetry/oteps/blob/master/text/0035-opentelemetry-protocol.md#throttling
Without having access to the Status, a client-provided backoff function is unable to conform to the throttling protocol, even though in all other respects such as backoff, the grpc_retry middleware can be configured to work as desired.
I think maybe in this specific case we should just add a way to automatically support this, as it's a generic gRPC status error detail. Regardless, sorry if I was being unclear, I'm asking what kind of API changes you expect here? Should we add an err
parameter, or magically hide in the context or something?
I was expecting it may be useful for the backoff function to get the err
parameter from the last unsuccessful call passed to it.
This seems a reasonable ask for v2, WDYT @bwplotka?
Definitely. Help wanted to improve it on v2 branch.