rpc

package
Version: v0.1.36 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: Apache-2.0 Imports: 19 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientConn

func ClientConn(cfg ClientCfg) (conn *grpc.ClientConn, err error)

ClientConn opens client connection with given configuration.

func PrepareServe

func PrepareServe(cfg *ServerCfg) (s *grpc.Server, lis net.Listener, err error)

func Serve

func Serve(cfg *ServerCfg)

Serve builds up the gRPC server and starts to serve. Note that the function blocks. In most cases you should start it as goroutine. To be able to gracefully stop the gRPC server you should call PrepareServe which builds everything ready but leaves calling the grpcServer.Serve for you.

func Server

func Server(cfg *ServerCfg) (s *grpc.Server, err error)

Server creates a gRPC server with TLS and JWT token authorization.

Types

type CertFiles

type CertFiles struct {
	CertFile string
	KeyFile  string
}

CertFiles is helper struct to keep both needed certification files together.

type ClientCfg

type ClientCfg struct {
	*PKI
	JWT  string
	Addr string
	Opts []grpc.DialOption
}

ClientCfg is gRPC client initialization and configuration struct.

type PKI

type PKI struct {
	ServerName string
	Server     CertFiles
	Client     CertFiles
}

PKI is helper struct to keep need certification files for both S/C.

func LoadPKI

func LoadPKI(tlsPath string) *PKI

func LoadPKIWithServerName added in v0.1.7

func LoadPKIWithServerName(tlsPath, serverName string) *PKI

type ServerCfg

type ServerCfg struct {
	*PKI
	Port      int
	TestLis   *bufconn.Listener
	Register  func(s *grpc.Server) error
	JWTSecret string
}

ServerCfg is gRPC server configuration struct for service init

Jump to

Keyboard shortcuts

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