Documentation ¶
Overview ¶
+kubebuilder:validation:Optional
Index ¶
- func ClientModule() fx.Option
- func GMuxServerModule() fx.Option
- func RegisterGRPCServerMetrics(metrics *grpc_prometheus.ServerMetrics, pr *prometheus.Registry) error
- func RegisterInfoService(server *grpc.Server)
- func ServerModule() fx.Option
- type BackoffConfig
- type ClientConnectionBuilder
- type ClientConnectionWrapper
- type ClientConstructor
- type GRPCClientConfig
- type GRPCServerConfig
- type InfoService
- type LogEvent
- func (e LogEvent) Bool(key string, b bool) LogEvent
- func (e LogEvent) Code(code codes.Code) LogEvent
- func (e LogEvent) Err(err error) LogEvent
- func (e LogEvent) Float32(key string, f float32) LogEvent
- func (e LogEvent) Float64(key string, f float64) LogEvent
- func (e LogEvent) Int(key string, i int) LogEvent
- func (e LogEvent) Interface(key string, i interface{}) LogEvent
- func (e LogEvent) Msg(msg string) error
- func (e LogEvent) Send() error
- func (e LogEvent) Str(key, val string) LogEvent
- func (e LogEvent) Stringer(key string, val fmt.Stringer) LogEvent
- type ServerConstructor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientModule ¶
ClientModule is an fx module that provides annotated grpc ClientConnectionBuilder.
func GMuxServerModule ¶
GMuxServerModule is an fx module that provides annotated gRPC Server using gmux provided listener and registers its metrics with the prometheus registry.
func RegisterGRPCServerMetrics ¶
func RegisterGRPCServerMetrics(metrics *grpc_prometheus.ServerMetrics, pr *prometheus.Registry) error
RegisterGRPCServerMetrics registers a collection of metrics provided by grpc_prometheus.ServerMetrics with a prometheus registry.
func RegisterInfoService ¶
RegisterInfoService registers the InfoService implementation with the provided grpc server.
func ServerModule ¶
ServerModule is an fx module that provides annotated gRPC Server using the default listener and registers its metrics with the prometheus registry.
Types ¶
type BackoffConfig ¶
type BackoffConfig struct { // Base Delay BaseDelay config.Duration `json:"base_delay" validate:"gte=0" default:"1s"` // Max Delay MaxDelay config.Duration `json:"max_delay" validate:"gte=0" default:"120s"` // Backoff multiplier Multiplier float64 `json:"multiplier" validate:"gte=0" default:"1.6"` // Jitter Jitter float64 `json:"jitter" validate:"gte=0" default:"0.2"` }
BackoffConfig holds configuration for gRPC client backoff. swagger:model +kubebuilder:object:generate=true
func (*BackoffConfig) DeepCopy ¶
func (in *BackoffConfig) DeepCopy() *BackoffConfig
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackoffConfig.
func (*BackoffConfig) DeepCopyInto ¶
func (in *BackoffConfig) DeepCopyInto(out *BackoffConfig)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ClientConnectionBuilder ¶
type ClientConnectionBuilder interface { AddOptions(opts ...grpc.DialOption) ClientConnectionBuilder Build() ClientConnectionWrapper }
ClientConnectionBuilder is a convenience builder to gather []grpc.DialOption.
type ClientConnectionWrapper ¶
type ClientConnectionWrapper interface { // Context can be nil Dial(ctx context.Context, target string, extraOptions ...grpc.DialOption) (*grpc.ClientConn, error) }
ClientConnectionWrapper is a convenience wrapper to support predefined dial Options provided by ClientConnectionBuilder.
type ClientConstructor ¶
type ClientConstructor struct { Name string ConfigKey string DefaultConfig GRPCClientConfig }
ClientConstructor holds fields to create an annotated instance of ClientConnectionBuilder.
func (ClientConstructor) Annotate ¶
func (c ClientConstructor) Annotate() fx.Option
Annotate creates an annotated instance of gRPC ClientConnectionBuilder.
type GRPCClientConfig ¶
type GRPCClientConfig struct { // Minimum connection timeout MinConnectionTimeout config.Duration `json:"min_connection_timeout" validate:"gte=0" default:"20s"` // Client TLS configuration ClientTLSConfig tlsconfig.ClientTLSConfig `json:"tls"` // Backoff configuration Backoff BackoffConfig `json:"backoff"` // Disable ClientTLS Insecure bool `json:"insecure" default:"false"` // Use HTTP CONNECT Proxy UseProxy bool `json:"use_proxy" default:"false"` }
GRPCClientConfig holds configuration for gRPC Client. swagger:model +kubebuilder:object:generate=true
func (*GRPCClientConfig) DeepCopy ¶
func (in *GRPCClientConfig) DeepCopy() *GRPCClientConfig
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GRPCClientConfig.
func (*GRPCClientConfig) DeepCopyInto ¶
func (in *GRPCClientConfig) DeepCopyInto(out *GRPCClientConfig)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type GRPCServerConfig ¶
type GRPCServerConfig struct { // Connection timeout ConnectionTimeout config.Duration `json:"connection_timeout" validate:"gte=0s" default:"120s"` // Buckets specification in latency histogram LatencyBucketsMS []float64 `json:"latency_buckets_ms" validate:"gte=0" default:"[10.0,25.0,100.0,250.0,1000.0]"` // Enable Reflection EnableReflection bool `json:"enable_reflection" default:"false"` }
GRPCServerConfig holds configuration for gRPC Server. swagger:model +kubebuilder:object:generate=true
func (*GRPCServerConfig) DeepCopy ¶
func (in *GRPCServerConfig) DeepCopy() *GRPCServerConfig
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GRPCServerConfig.
func (*GRPCServerConfig) DeepCopyInto ¶
func (in *GRPCServerConfig) DeepCopyInto(out *GRPCServerConfig)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type InfoService ¶
type InfoService struct {
infov1.UnimplementedInfoServiceServer
}
InfoService is the implementation of the infov1.InfoServiceServer interface.
func (*InfoService) Process ¶
func (vh *InfoService) Process(ctx context.Context, req *emptypb.Empty) (*infov1.ProcessInfo, error)
Process returns the process info of the service.
func (*InfoService) Version ¶
func (vh *InfoService) Version(ctx context.Context, req *emptypb.Empty) (*infov1.VersionInfo, error)
Version returns the version of the service.
type LogEvent ¶
type LogEvent struct {
// contains filtered or unexported fields
}
LogEvent wraps *zerolog.Event, so that sending an event also returns an grpc error
LogEvent also forwards _some_ builder-functions (like Str()) to the underlying zerolog.Event. This is just a sugar, as you can always use WithEvent on the whole chain.
func Bug ¶
func Bug() LogEvent
Bug is equivalent to WithLogEvent(log.Bug()).Code(codes.Internal)
Example: return nil, grpc.Bug().Msg("impossible happened").
func BugWithLogger ¶
BugWithLogger is equivalent to WithLogEvent(logger.Bug()).Code(codes.Internal).
func LoggedError ¶
LoggedError wraps zerolog.Event so that sending an event will also return a grpc error.
GRPC error code should be provided using Code(), otherwise, the error will use codes.Unknown.
Example:
return nil, grpc.LoggedError(log.Autosample().Warn()). Code(codes.InvalidArgument). Msg("missing frobnicator")
func (LogEvent) Code ¶
Code sets the gRPC code to be used in error returned via Msg() or Send()
Additionally, it adds the code field to the event.
func (LogEvent) Err ¶
Err adds the field "error" with serialized err to the *Event context. If err is nil, no field is added.
To customize the key name, change zerolog.ErrorFieldName.
If Stack() has been called before and zerolog.ErrorStackMarshaler is defined, the err is passed to ErrorStackMarshaler and the result is appended to the zerolog.ErrorStackFieldName.
func (LogEvent) Msg ¶
Msg sends the *Event with msg added as the message field if not empty.
Msg returns grpc error using given msg as message and code previously set with Code
NOTICE: once this method is called, the LogEvent should be disposed. Calling Msg twice can have unexpected result.
type ServerConstructor ¶
type ServerConstructor struct { // Name of grpc server instance -- empty for main server Name string // Name of listener instance ListenerName string // Viper config key/server name ConfigKey string // Additional server Options ServerOptions []grpc.ServerOption // Default Server Config DefaultConfig GRPCServerConfig }
ServerConstructor holds fields to create an annotated gRPC Server.
func (ServerConstructor) Annotate ¶
func (constructor ServerConstructor) Annotate() fx.Option
Annotate creates an annotated instance of gRPC Server.