grpcutil

package
v0.0.0-...-7c66ffc Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package grpcutil contains utility functions to create gRPC clients and servers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGRPCClientConnection

func NewGRPCClientConnection(config GRPCClientParam) (*grpc.ClientConn, error)

NewGRPCClientConnection is a factory method to create gRPC client connections

Types

type GRPCClientParam

type GRPCClientParam struct {
	ServerEndpoint     string `param:"desc=Server endpoint;default=localhost:10000"` // Host:port address of the server
	TLS                bool   `param:"desc=Enable TLS;default=false"`                // TLS enabled
	CAFile             string `param:"desc=CA certificate file;file"`                // CA cert file
	ServerHostOverride string `param:"desc=Host name override for certificate"`      // Server name returned from the TLS handshake (for debugging)

}

GRPCClientParam contains gRPC client parameters. These paramters are the same for every gRPC client across the system.

type GRPCServer

type GRPCServer interface {
	// Start launches the server in the foreground
	Start(registerFunc func(s *grpc.Server)) error
	// Launch launches the server in the background
	Launch(registerFunc func(s *grpc.Server), timeout time.Duration) error
	// Endpoint returns the server's endpoint
	Endpoint() string
	// Stop shuts down the server
	Stop()
}

GRPCServer is the common interface for GRPC servers

func NewGRPCServer

func NewGRPCServer(params GRPCServerParam) (GRPCServer, error)

NewGRPCServer configures a new GRPC server. A port will be allocated for the server

type GRPCServerParam

type GRPCServerParam struct {
	Endpoint string `param:"desc=Server endpoint;default=localhost:0"`
	TLS      bool   `param:"desc=Enable TLS;default=false"`
	CertFile string `param:"desc=Certificate file;file"`
	KeyFile  string `param:"desc=Certificate key file;file"`
}

GRPCServerParam holds parameters for a GRPC server

Jump to

Keyboard shortcuts

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