grpc

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2022 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

+kubebuilder:validation:Optional

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientModule

func ClientModule() fx.Option

ClientModule is an fx module that provides annotated grpc ClientConnectionBuilder.

func GMuxServerModule

func GMuxServerModule() fx.Option

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

func RegisterInfoService(server *grpc.Server)

RegisterInfoService registers the InfoService implementation with the provided grpc server.

func ServerModule

func ServerModule() fx.Option

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 added in v0.1.2

func (in *BackoffConfig) DeepCopy() *BackoffConfig

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackoffConfig.

func (*BackoffConfig) DeepCopyInto added in v0.1.2

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 config
	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 added in v0.1.2

func (in *GRPCClientConfig) DeepCopy() *GRPCClientConfig

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GRPCClientConfig.

func (*GRPCClientConfig) DeepCopyInto added in v0.1.2

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"`
	// Enable Reflection
	EnableReflection bool `json:"enable_reflection" default:"false"`
	// 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]"`
}

GRPCServerConfig holds configuration for GRPC Server. swagger:model +kubebuilder:object:generate=true

func (*GRPCServerConfig) DeepCopy added in v0.1.2

func (in *GRPCServerConfig) DeepCopy() *GRPCServerConfig

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GRPCServerConfig.

func (*GRPCServerConfig) DeepCopyInto added in v0.1.2

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) Host

func (vh *InfoService) Host(ctx context.Context, req *emptypb.Empty) (*infov1.HostInfo, error)

Host returns the hostname of the service.

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 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
	// Default Server Config
	DefaultConfig GRPCServerConfig
	// Additional server Options
	ServerOptions []grpc.ServerOption
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL