-
Notifications
You must be signed in to change notification settings - Fork 702
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
grpc_retry.WithMax(), how to use it properly? #37
Comments
@feliksik In order to use the These interceptors are the things that actually drive the calling logic, and the You spotted a bug that I have no immediate way of fixing. You see, the
As such, the code panics. Sadly there are two ways around this:
|
Let's see what upstream responds, this is a snippet of a test that will make it fail: func (s *RetrySuite) TestCallOptionsDontPanicWithoutMiddleware() {
s.srv.resetFailingConfiguration(3, codes.DataLoss, noSleep) // see retriable_errors
nonMiddlewareClient := s.NewClient()
_, err := nonMiddlewareClient.Ping(s.SimpleCtx(), goodPing,
grpc_retry.WithMax(5),
//grpc_retry.WithBackoff(grpc_retry.BackoffLinear(1*time.Millisecond)),
//grpc_retry.WithCodes(codes.Aborted, codes.InvalidArgument),
//grpc_retry.WithPerRetryTimeout(30*time.Millisecond),
)
require.NoError(s.T(), err, "the third invocation should succeed")
} |
Thanks for the clear response! I'll just make sure to use an interceptor in Dial() then. When the NoopOption would be implemented upstream, I'm still not sure how the internals work to apply the grpc_retry.WithMax(5) magically to the correct interceptor... but I can work around that. |
When the NoopOption is implemented, you will still need to have an interceptor implemented. A simple option is not going to be enough. |
So it seems upstream has a PR for it: So there's hope for a proper fix! :) |
Yup, there's a fix for it upstream, and we'll wait for the 1.4 gRPC Go release. |
in this example, we see the following code:
But when I use one of those "option modifiers" as grpc_retry.WithMax() in a client call, it fails with a nullpointer exception. This is because the callOption wasn't set.
It seems to work well when I pass it as a modifier to the constructor of grpc_retry.UnaryClientInterceptor, such as in the test.
I do not yet fully understand the code architecture, and I don't know how a
grpc.CallOption
is to be usted. My question is: Am I overlooking something? Is the example just wrong? Or is the implementation wrong?The text was updated successfully, but these errors were encountered: