MCPcopy
hub / github.com/grafana/dskit / newBackoffRetry

Function newBackoffRetry

crypto/tls/test/tls_integration_test.go:696–713  ·  view source on GitHub ↗
(cfg backoff.Config)

Source from the content-addressed store, hash-verified

694}
695
696func 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.
716func newRateLimiter(cfg *grpcConfig) grpc.UnaryClientInterceptor {

Callers 1

DialOptionMethod · 0.85

Calls 4

NewFunction · 0.92
OngoingMethod · 0.80
WaitMethod · 0.45
ErrMethod · 0.45

Tested by

no test coverage detected