rpc

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConfigNameEnableRPCLogging is the config name for enabling RPC logging.
	ConfigNameEnableRPCLogging = "logging.rpc"
)

Variables

This section is empty.

Functions

func GRPCClientFromConfig

func GRPCClientFromConfig(cfg config.View, prefix string) (*grpc.ClientConn, error)

GRPCClientFromConfig creates a gRPC client connection from a configuration.

func GRPCClientFromEndpoint

func GRPCClientFromEndpoint(cfg config.View, address string) (*grpc.ClientConn, error)

GRPCClientFromEndpoint creates a gRPC client connection from endpoint.

func GRPCClientFromParams

func GRPCClientFromParams(params *ClientParams) (*grpc.ClientConn, error)

GRPCClientFromParams creates a gRPC client connection from the parameters.

func HTTPClientFromConfig

func HTTPClientFromConfig(cfg config.View, prefix string) (*http.Client, string, error)

HTTPClientFromConfig creates a HTTP client from from a configuration.

func HTTPClientFromEndpoint

func HTTPClientFromEndpoint(cfg config.View, address string) (*http.Client, string, error)

HTTPClientFromEndpoint creates a HTTP client from from endpoint.

func HTTPClientFromParams

func HTTPClientFromParams(params *ClientParams) (*http.Client, string, error)

HTTPClientFromParams creates a HTTP client from the parameters.

Types

type ClientCache

type ClientCache struct {
	// contains filtered or unexported fields
}

ClientCache holds GRPC and HTTP clients based on an address.

func NewClientCache

func NewClientCache(cfg config.View) *ClientCache

NewClientCache creates a cache with all the clients.

func (*ClientCache) GetGRPC

func (cc *ClientCache) GetGRPC(address string) (*grpc.ClientConn, error)

GetGRPC gets a GRPC client with the address.

func (*ClientCache) GetHTTP

func (cc *ClientCache) GetHTTP(address string) (*http.Client, string, error)

GetHTTP gets a HTTP client with the address.

type ClientParams

type ClientParams struct {
	Address                 string
	TrustedCertificate      []byte
	EnableRPCLogging        bool
	EnableRPCPayloadLogging bool
	EnableMetrics           bool
}

ClientParams contains the connection parameters to connect to an Open Match service.

type GrpcHandler

type GrpcHandler func(*grpc.Server)

GrpcHandler binds gRPC services.

type GrpcProxyHandler

type GrpcProxyHandler func(context.Context, *runtime.ServeMux, string, []grpc.DialOption) error

GrpcProxyHandler binds HTTP handler to gRPC service.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server hosts a gRPC and HTTP server. All HTTP traffic is served from a common http.ServeMux.

func (*Server) Start

func (s *Server) Start(p *ServerParams) error

Start the gRPC+HTTP(s) REST server.

func (*Server) Stop

func (s *Server) Stop() error

Stop the gRPC+HTTP(s) REST server.

type ServerParams

type ServerParams struct {
	// ServeMux is the router for the HTTP server. You can use this to serve pages in addition to the HTTP proxy.
	// Do NOT register "/" handler because it's reserved for the proxy.
	ServeMux *http.ServeMux
	// contains filtered or unexported fields
}

ServerParams holds all the parameters required to start a gRPC server.

func NewServerParamsFromConfig

func NewServerParamsFromConfig(cfg config.View, prefix string, listen func(network, address string) (net.Listener, error)) (*ServerParams, error)

NewServerParamsFromConfig returns server Params initialized from the configuration file.

func NewServerParamsFromListeners

func NewServerParamsFromListeners(grpcL net.Listener, proxyL net.Listener) *ServerParams

NewServerParamsFromListeners returns server Params initialized with the ListenerHolder variables.

func (*ServerParams) AddHandleFunc

func (p *ServerParams) AddHandleFunc(handlerFunc GrpcHandler, grpcProxyHandler GrpcProxyHandler)

AddHandleFunc binds gRPC service handler and an associated HTTP proxy handler.

func (*ServerParams) AddHealthCheckFunc

func (p *ServerParams) AddHealthCheckFunc(handlerFunc func(context.Context) error)

AddHealthCheckFunc adds a readiness probe to tell Kubernetes the service is able to handle traffic.

func (*ServerParams) SetTLSConfiguration

func (p *ServerParams) SetTLSConfiguration(rootCaPublicCertificateFileData []byte, publicCertificateFileData []byte, privateKeyFileData []byte) *ServerParams

SetTLSConfiguration configures the server to run in TLS mode.

Jump to

Keyboard shortcuts

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