Documentation ¶
Index ¶
- func GetOrGenerateRequestID(ctx context.Context) context.Context
- func GetOrGenerateRequestIDForRequest(req *http.Request) context.Context
- func NewConnection(ctx context.Context, cfg Config, opts ...grpc.DialOption) (*grpc.ClientConn, error)
- func RequestIDClientInterceptor(ctx context.Context, method string, req, reply interface{}, ...) error
- func RequestIDInterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, ...) (interface{}, error)
- func RequestIDStreamInterceptor(srv interface{}, ss grpc.ServerStream, _ *grpc.StreamServerInfo, ...) error
- func WithClientName(ctx context.Context, clientName string) context.Context
- type Config
- type KeepAliveConfig
- type ServerStreamWithContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOrGenerateRequestID ¶
GetOrGenerateRequestID returns a context with request id set from the context or from metadata if it exists, otherwise it generates a new one.
func GetOrGenerateRequestIDForRequest ¶
GetOrGenerateRequestIDForRequest returns a context with request id set from the context or from metadata if it exists, otherwise it generates a new one.
func NewConnection ¶
func NewConnection(ctx context.Context, cfg Config, opts ...grpc.DialOption) (*grpc.ClientConn, error)
NewConnection establishes a new grpc connection based on config and additional dial options
func RequestIDClientInterceptor ¶
func RequestIDClientInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
RequestIDClientInterceptor is a client interceptor that sets the request id on the context for any outgoing calls.
func RequestIDInterceptor ¶
func RequestIDInterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
RequestIDInterceptor is a server interceptor that sets the request id on the context for any incoming calls.
func RequestIDStreamInterceptor ¶
func RequestIDStreamInterceptor(srv interface{}, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error
RequestIDStreamInterceptor is a server interceptor that sets the request id on the context for any incoming calls.
Types ¶
type Config ¶
type Config struct { Endpoint config.URL `json:"host" pflag:",Host to connect to"` Insecure bool `json:"insecure" pflag:",Whether to connect over insecure channel"` InsecureSkipVerify bool `` /* 186-byte string literal not displayed */ MinConnectTimeout config.Duration `json:"minConnectTimeout" pflag:",Minimum timeout for establishing a connection"` MaxBackoffDelay config.Duration `json:"maxBackoffDelay" pflag:",Max delay for grpc backoff"` PerRetryTimeout config.Duration `json:"perRetryTimeout" pflag:",gRPC per retry timeout"` MaxRetries int `json:"maxRetries" pflag:",Max number of gRPC retries"` ServiceConfig string `json:"serviceConfig" pflag:",Defines gRPC experimental JSON Service Config"` Backoff backoff.Config `json:"backoff" pflag:"-,Defines backoff config params"` KeepAliveConfig KeepAliveConfig `json:"keepAliveConfig" pflag:",Keep alive configuration"` }
func GetDefaultConfig ¶
func GetDefaultConfig() Config
GetDefaultConfig gets a copy of the default config
func (Config) GetPFlagSet ¶
GetPFlagSet will return strongly types pflags for all fields in Config and its nested types. The format of the flags is json-name.json-sub-name... etc.
type KeepAliveConfig ¶
type KeepAliveConfig struct { // After a duration of this time if the client doesn't see any activity it // pings the server to see if the transport is still alive. // If set below 10s, a minimum value of 10s will be used instead. Time config.Duration `` // The current default value is infinity. /* 149-byte string literal not displayed */ // After having pinged for keepalive check, the client waits for a duration // of Timeout and if no activity is seen even after that the connection is // closed. Timeout config.Duration `` // The current default value is 20 seconds. /* 176-byte string literal not displayed */ // If true, client sends keepalive pings even with no active RPCs. If false, // when there are no active RPCs, Time and Timeout will be ignored and no // keepalive pings will be sent. PermitWithoutStream bool `json:"permitWithoutStream" pflag:",If true, client sends keepalive pings even with no active RPCs."` // false by default. }
KeepAliveConfig contains configuration for keeping the connection alive. Copied and modified to work with config from: https://github.com/grpc/grpc-go/blob/master/keepalive/keepalive.go#L33
func (KeepAliveConfig) ToGrpcClientParameters ¶
func (c KeepAliveConfig) ToGrpcClientParameters() keepalive.ClientParameters
ToGrpcClientParameters converts KeepAliveConfig into keepalive.ClientParameters struct.
type ServerStreamWithContext ¶
type ServerStreamWithContext struct { grpc.ServerStream // contains filtered or unexported fields }
ServerStreamWithContext is a wrapper around grpc.ServerStream that allows us to override the context.
func (*ServerStreamWithContext) Context ¶
func (s *ServerStreamWithContext) Context() context.Context