grpc

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	BindAddress string     `json:"bind-address" mapstructure:"bind-address"`
	BindPort    int        `json:"bind-port"    mapstructure:"bind-port"`
	MaxMsgSize  int        `json:"max-msg-size" mapstructure:"max-msg-size"`
	TLS         TLSOptions `json:"tls"          mapstructure:"tls"`
}

Options contains configuration options for grpc server.

func NewOptions

func NewOptions() *Options

NewOptions return a new options for server.

func (*Options) AddFlags

func (o *Options) AddFlags(fs *pflag.FlagSet)

func (*Options) Address

func (o *Options) Address() string

Address join host IP address and host port number into an address string, like: 0.0.0.0:80.

func (*Options) Validate

func (o *Options) Validate() []error

type Server

type Server interface {
	// Setup setups the grpc server. Setup should be called before Run.
	Setup(SetupFunc) error
	// Run starts the grpc server.
	Run() error
	// Close shutdowns the grpc server.
	Close()
}

Server is the interface of grpc server.

func New

func New(opts *Options) Server

New returns a new grpc server.

type SetupFunc

type SetupFunc func(s *grpc.Server) error

SetupFunc is the func used to set up the engine.

type TLSOptions

type TLSOptions struct {
	Enabled bool `json:"enabled"          mapstructure:"enabled"`
	// CertFile is a file containing a PEM-encoded certificate, and possibly the complete certificate chain
	CertFile string `json:"cert-file"        mapstructure:"cert-file"`
	// KeyFile is a file containing a PEM-encoded private key for the certificate specified by CertFile
	KeyFile string `json:"private-key-file" mapstructure:"private-key-file"`
}

TLSOptions contains configuration for TLS.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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