-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: adds clientside retries #66
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handful of thoughts / questions about consistency with other languages, plus need to make sure we have a story around non-idempotent request types
RetryStrategy: NewStaticRetryStrategy(&RetryStrategyProps{ | ||
RetryableRequestStatuses: defaultRetryableStatusCodes, | ||
MaxRetries: defaultMaxRetries, | ||
PerRetryTimeout: overallRequestTimeout / defaultMaxRetries, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk if we want to introduce this yet? it's a little different from the other sdks, was just planning on sticking to the most basic FixedCount strategy for now and circling back later.
} | ||
|
||
type RetryStrategy interface { | ||
// GetRetryableRequestStatuses Which status codes to retry requests on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the other sdks this interface just has one method
|
||
type RetryStrategyProps struct { | ||
// Which status codes to retry requests on | ||
RetryableRequestStatuses []codes.Code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might want to take a look at how i did this in .NET SDK. We need to be able to decide based on status and the request type, so I created a RetryEligibilityStrategy interface that can be re-used across different retry strategies:
grpc.WithTransportCredentials(credentials.NewTLS(config)), | ||
grpc.WithUnaryInterceptor(interceptor.AddHeadersInterceptor(authToken)), | ||
grpc.WithUnaryInterceptor(grpc_retry.UnaryClientInterceptor([]grpc_retry.CallOption{ | ||
grpc_retry.WithMax(request.Config.GetRetryStrategy().GetMaxRetries()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like maybe you are trying to use an off-the-shelf one here? That's appealing but in most of the other languages I'm finding that the off-the-shelf ones can't actually handle our use case (e.g. no way to specify whether to retry based on request type, and we don't want to retry non-idempotent operations)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also FWIW I haven't necessarily been adding retries for control plane in some of the other sdks for now, but i don't feel strongly about that
grpc.WithStreamInterceptor(grpc_retry.StreamClientInterceptor([]grpc_retry.CallOption{ | ||
grpc_retry.WithMax(request.Config.GetRetryStrategy().GetMaxRetries()), | ||
grpc_retry.WithPerRetryTimeout(request.Config.GetRetryStrategy().GetPerRetryTimeout()), | ||
grpc_retry.WithCodes(request.Config.GetRetryStrategy().GetRetryableRequestStatuses()...), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does retry mean for a stream interceptor?
grpc.WithUnaryInterceptor(grpc_retry.UnaryClientInterceptor([]grpc_retry.CallOption{ | ||
grpc_retry.WithMax(request.Config.GetRetryStrategy().GetMaxRetries()), | ||
grpc_retry.WithPerRetryTimeout(request.Config.GetRetryStrategy().GetPerRetryTimeout()), | ||
grpc_retry.WithCodes(request.Config.GetRetryStrategy().GetRetryableRequestStatuses()...), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same thoughts here about off-the-shelf and support for configuring by request type
Closes #44
Closes #49