server

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: BSD-3-Clause Imports: 30 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// 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

This section is empty.

Types

type Discover added in v0.2.12

type Discover interface {
	ServiceRegister(ctx context.Context, name, addr string, tags []string, meta map[string]string) error
	ServiceDeregister(ctx context.Context, name string) error
}

Discover service discovery

type Option

type Option func(*options)

Option the option for this module

func WithAuthFunc added in v0.2.18

func WithAuthFunc(a interceptor.Authorize) Option

WithAuthFunc

func WithDiscover added in v0.2.12

func WithDiscover(d Discover, tags ...string) Option

WithDiscover

func WithGrpcAddr

func WithGrpcAddr(addr string) Option

WithGrpcAddr

func WithGrpcServerOption

func WithGrpcServerOption(opts ...grpc.ServerOption) Option

WithGRPCServerOption with other grpc options

func WithHttpAddr

func WithHttpAddr(addr string) Option

WithHttpAddr

func WithHttpServerOption

func WithHttpServerOption(opts ...mux.Optional) Option

WithHTTPServerOption with http server options

func WithLimiter added in v0.2.18

func WithLimiter(l *limit.Limiter) Option

WithLimiter performs rate limiting on the request.

func WithLogger

func WithLogger(logger grpc_logging.Logger) Option

WithLogger

func WithLoggingDecider

func WithLoggingDecider(decider logging.Decider) Option

WithLoggingDecider Decider how log output.

func WithMetricsAddr added in v0.2.29

func WithMetricsAddr(addr string) Option

WithMetricsAddr

func WithRequestFieldExtractor

func WithRequestFieldExtractor(f logging.RequestFieldExtractorFunc) Option

WithRequestFieldExtractor customizes the function for extracting log fields from protobuf messages, for unary and server-streamed methods only.

func WithResponseFieldExtractor

func WithResponseFieldExtractor(f logging.ResponseFieldExtractorFunc) Option

WithResponseFieldExtractor customizes the function for extracting log fields from protobuf messages, for unary and server-streamed methods only.

func WithStreamServerInterceptor

func WithStreamServerInterceptor(f grpc.StreamServerInterceptor) Option

WithStreamServerInterceptor

func WithTags added in v0.2.22

func WithTags(tags []string) Option

WithTags

func WithTracer

func WithTracer(tracer opentracing.Tracer) Option

WithTracer

func WithUnaryServerInterceptor

func WithUnaryServerInterceptor(f grpc.UnaryServerInterceptor) Option

WithUnaryServerInterceptor

type Server

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

Server the grpc server

func NewServer

func NewServer(ctx context.Context, logger *zap.Logger, opts ...Option) *Server

NewServer new grpc server with all common middleware.

func (*Server) Close

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

Close K8s closes after 60 seconds by default refer: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/

func (*Server) Handle

func (s *Server) Handle(method, path string, h runtime.HandlerFunc)

Handle registering HTTP handler

func (*Server) RegisterService

func (s *Server) RegisterService(ctx context.Context, desc *grpc.ServiceDesc, serviceImpl interface{})

RegisterService registering gRPC service

func (*Server) ServeMux

func (s *Server) ServeMux() *runtime.ServeMux

ServeMux retrun gRPC-GateWay server mux

func (*Server) Start

func (s *Server) Start(ctx context.Context)

Start

Directories

Path Synopsis
mux

Jump to

Keyboard shortcuts

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