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

Method DialOption

crypto/tls/test/tls_integration_test.go:667–694  ·  view source on GitHub ↗

DialOption returns the config as a grpc.DialOptions.

()

Source from the content-addressed store, hash-verified

665
666// DialOption returns the config as a grpc.DialOptions.
667func (cfg *grpcConfig) DialOption() ([]grpc.DialOption, error) {
668 var opts []grpc.DialOption
669 tlsOpts, err := cfg.TLS.GetGRPCDialOptions(cfg.TLSEnabled)
670 if err != nil {
671 return nil, err
672 }
673 opts = append(opts, tlsOpts...)
674
675 var unaryClientInterceptors []grpc.UnaryClientInterceptor
676 if cfg.BackoffOnRatelimits {
677 unaryClientInterceptors = append([]grpc.UnaryClientInterceptor{newBackoffRetry(cfg.BackoffConfig)}, unaryClientInterceptors...)
678 }
679
680 if cfg.RateLimit > 0 {
681 unaryClientInterceptors = append([]grpc.UnaryClientInterceptor{newRateLimiter(cfg)}, unaryClientInterceptors...)
682 }
683
684 return append(
685 opts,
686 grpc.WithDefaultCallOptions(cfg.CallOptions()...),
687 grpc.WithChainUnaryInterceptor(unaryClientInterceptors...),
688 grpc.WithKeepaliveParams(keepalive.ClientParameters{
689 Time: time.Second * 20,
690 Timeout: time.Second * 10,
691 PermitWithoutStream: true,
692 }),
693 ), nil
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 {

Callers 1

Calls 4

CallOptionsMethod · 0.95
newBackoffRetryFunction · 0.85
newRateLimiterFunction · 0.85
GetGRPCDialOptionsMethod · 0.80

Tested by

no test coverage detected