server

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: BSD-3-Clause Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*options)

Option the option for this module

func WithConsul

func WithConsul(consul *consulApi.Client) Option

WithConsul

func WithGrpcAddr

func WithGrpcAddr(addr string) Option

WithGrpcAddr

func WithGrpcServerOption

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

WithGRPCServerOption with other grpc options

func WithHttp

func WithHttp(h bool) Option

WithHttp

func WithHttpAddr

func WithHttpAddr(addr string) Option

WithHttpAddr

func WithHttpServerOption

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

WithHTTPServerOption with http server options

func WithLogger

func WithLogger(logger grpc_logging.Logger) Option

WithLogger

func WithLoggingDecider

func WithLoggingDecider(decider logging.Decider) Option

WithLoggingDecider

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 WithTracer

func WithTracer(tracer opentracing.Tracer) Option

WithTracer

func WithUnaryServerInterceptor

func WithUnaryServerInterceptor(f grpc.UnaryServerInterceptor) Option

WithUnaryServerInterceptor

type RegistrarFunc

type RegistrarFunc func(s *grpc.Server)

RegistrarFunc

type Server

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

Server the grpc server

func NewServer

func NewServer(logger *zap.Logger, regFunc RegistrarFunc, opts ...Option) *Server

NewServer new grpc server with all common middleware.

func (*Server) Close

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

Close 默认超时1分钟再关闭,K8S service 关闭策略 refer: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/

func (*Server) Handle

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

Handle 注册自定义HTTP路由

func (*Server) RegisterService

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

RegisterService 注册函数

func (*Server) ServeMux

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

ServeMux 返回grpc gateay 原生的 server mux

func (*Server) Start

func (s *Server) Start()

Start

Jump to

Keyboard shortcuts

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