(cfg backoff.Config)
| 694 | } |
| 695 | |
| 696 | func newBackoffRetry(cfg backoff.Config) grpc.UnaryClientInterceptor { |
| 697 | return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { |
| 698 | backoff := backoff.New(ctx, cfg) |
| 699 | for backoff.Ongoing() { |
| 700 | err := invoker(ctx, method, req, reply, cc, opts...) |
| 701 | if err == nil { |
| 702 | return nil |
| 703 | } |
| 704 | |
| 705 | if status.Code(err) != codes.ResourceExhausted { |
| 706 | return err |
| 707 | } |
| 708 | |
| 709 | backoff.Wait() |
| 710 | } |
| 711 | return backoff.Err() |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | // newRateLimiter creates a UnaryClientInterceptor for client side rate limiting. |
| 716 | func newRateLimiter(cfg *grpcConfig) grpc.UnaryClientInterceptor { |
no test coverage detected