grpcServer

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DialTimeout the timeout of create connection
	DialTimeout = 5 * time.Second

	// BackoffMaxDelay provided maximum delay when backing off after failed connection attempts.
	BackoffMaxDelay = 3 * time.Second

	// KeepAliveTime is the duration of time after which if the client doesn't see
	// any activity it pings the server to see if the transport is still alive.
	KeepAliveTime = time.Duration(10) * time.Second

	// KeepAliveTimeout is the duration of time for which the client waits after having
	// pinged for keepalive check and if no activity is seen even after that the connection
	// is closed.
	KeepAliveTimeout = time.Duration(3) * time.Second

	// InitialWindowSize we set it 1GB is to provide system's throughput.
	InitialWindowSize = 1 << 30

	// InitialConnWindowSize we set it 1GB is to provide system's throughput.
	InitialConnWindowSize = 1 << 30

	// MaxSendMsgSize set max gRPC request message size sent to server.
	// If any request message size is larger than current value, an error will be reported from gRPC.
	MaxSendMsgSize = 4 << 30

	// MaxRecvMsgSize set max gRPC receive message size received from server.
	// If any message size is larger than current value, an error will be reported from gRPC.
	MaxRecvMsgSize = 4 << 30
)

Variables

This section is empty.

Functions

func AddComponent

func AddComponent(register Register)

Types

type Config

type Config struct {
	Addr              string        `yaml:"addr"`
	ServiceName       string        `yaml:"service_name"`
	ConnectionTimeout int           `yaml:"connection_timeout"` //所有连接的超时设置
	KeepAliveConf     keepAliveConf `yaml:"keep_alive_conf"`

	Register `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

type Option

type Option func(c *Server)

func SetConf

func SetConf(c Config) Option

func SetRegister

func SetRegister(register rpcx.Register) Option

type Register

type Register func(server *grpc.Server)

type Server

type Server struct {
	Register rpcx.Register
	// contains filtered or unexported fields
}

func NewServer

func NewServer(f func(*Server), opts ...Option) *Server

func (*Server) Server

func (s *Server) Server() *grpc.Server

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

func (*Server) Start

func (s *Server) Start()

func (*Server) Use

func (s *Server) Use(handlers ...grpc.UnaryServerInterceptor) *Server

Jump to

Keyboard shortcuts

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