server

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxMsgSize define maximum message size that server can send
	// or receive.  Default value is 4MB.
	DefaultMaxMsgSize = 1024 * 1024 * 4
	// DefaultAddress default grpc server address
	DefaultAddress = ":8081"
)

Variables

View Source
var (
	DefaultServerParameters = keepalive.ServerParameters{
		MaxConnectionIdle:     30 * time.Second,
		MaxConnectionAge:      55 * time.Second,
		MaxConnectionAgeGrace: 5 * time.Second,
		Time:                  10 * time.Second,
		Timeout:               2 * time.Second,
	}
	DefaultEnforcementPolicy = keepalive.EnforcementPolicy{
		MinTime:             5 * time.Second,
		PermitWithoutStream: true,
	}
	DefaultCfg = Cfg{
		MaxMsgSize: DefaultMaxMsgSize,
	}
)

Functions

func SetLog

func SetLog(l logger.Logger)

Types

type Cfg

type Cfg struct {
	MaxMsgSize int
	TlsCfg     *tls.Config
	Address    string
	ForceStop  bool
}

type GrpcServer

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

func New

func New(cfgs ...Cfg) *GrpcServer

func (GrpcServer) AddStreamServerInterceptors

func (g GrpcServer) AddStreamServerInterceptors(interceptors ...grpc.StreamServerInterceptor)

func (GrpcServer) AddUnaryServerInterceptors

func (g GrpcServer) AddUnaryServerInterceptors(interceptors ...grpc.UnaryServerInterceptor)

func (GrpcServer) EnableDebug

func (g GrpcServer) EnableDebug()

EnableDebug https://github.com/grpc/grpc-experiments/tree/master/gdebug

func (GrpcServer) GetDefaultServerOpts

func (g GrpcServer) GetDefaultServerOpts() []grpc.ServerOption

func (GrpcServer) Init

func (g GrpcServer) Init(opts ...grpc.ServerOption) (gErr error)

func (GrpcServer) RegisterService

func (g GrpcServer) RegisterService(register interface{}, handler interface{}) (err error)

RegisterService 注册grpc handler

func (GrpcServer) Start

func (g GrpcServer) Start() (gErr error)

func (GrpcServer) Stop

func (g GrpcServer) Stop() error

Jump to

Keyboard shortcuts

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