Documentation
¶
Index ¶
- Variables
- func GetCtxValue(ctx context.Context, key ctxkeys.CtxKey) interface{}
- func GetGRPCClientIP(ctx context.Context) (string, error)
- func GetSliceFromMD(md metadata.MD, key ctxkeys.CtxKey) []string
- func GetStringFromMD(md metadata.MD, key ctxkeys.CtxKey) string
- func IncomingMD(ctx context.Context) metadata.MD
- func OutgoingMD(ctx context.Context) metadata.MD
- func SetCtxValue(ctx context.Context, key ctxkeys.CtxKey, val interface{}) context.Context
- type Logger
- type LoggerFunc
- type Option
- func WithEnablePrometheus() Option
- func WithEnableRequestAccess() Option
- func WithEnableRequestValidator() Option
- func WithGRPCNetwork(network string) Option
- func WithGRPCServerOption(serverOption ...grpc.ServerOption) Option
- func WithInterruptSignals(signal ...os.Signal) Option
- func WithLogger(logger Logger) Option
- func WithRecovery(f func()) Option
- func WithShutdownFunc(f func()) Option
- func WithShutdownTimeout(timeout time.Duration) Option
- func WithStreamInterceptor(streamInterceptor ...grpc.StreamServerInterceptor) Option
- func WithUnaryInterceptor(unaryInterceptor ...grpc.UnaryServerInterceptor) Option
- type Service
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvokeGRPCClientIP get grpc request client ip fail. ErrInvokeGRPCClientIP = errors.New("invoke from context failed") // ErrPeerAddressNil gRPC peer address is nil. ErrPeerAddressNil = errors.New("peer address is nil") )
Functions ¶
func GetCtxValue ¶
GetCtxValue returns ctx when you set key/value into ctx
func GetGRPCClientIP ¶
GetGRPCClientIP get client ip address from context
func GetSliceFromMD ¶
GetSliceFromMD returns []string from md
func GetStringFromMD ¶
GetStringFromMD returns string from md
func IncomingMD ¶
IncomingMD returns metadata.MD from incoming ctx get request metadata this method is mainly used at the server end to get the relevant metadata data
func OutgoingMD ¶
OutgoingMD returns metadata.MD from outgoing ctx Use this method when you pass ctx to a downstream service
Types ¶
type LoggerFunc ¶
type LoggerFunc func(string, ...interface{})
LoggerFunc is a bridge between Logger and any third party logger.
func (LoggerFunc) Printf ¶
func (f LoggerFunc) Printf(msg string, args ...interface{})
Printf implements Logger interface.
type Option ¶
type Option func(s *Service)
Option for grpc service option
func WithEnablePrometheus ¶
func WithEnablePrometheus() Option
WithEnablePrometheus enable prometheus
func WithEnableRequestAccess ¶
func WithEnableRequestAccess() Option
WithEnableRequestAccess request access log config
func WithEnableRequestValidator ¶
func WithEnableRequestValidator() Option
WithEnableRequestValidator set request validator
func WithGRPCNetwork ¶
WithGRPCNetwork set gRPC start network type
func WithGRPCServerOption ¶
func WithGRPCServerOption(serverOption ...grpc.ServerOption) Option
WithGRPCServerOption returns an Option to append a gRPC server option
func WithInterruptSignals ¶
WithInterruptSignals returns an Option to append a interrupt signal
func WithShutdownFunc ¶
func WithShutdownFunc(f func()) Option
WithShutdownFunc returns an Option to register a function which will be called when server shutdown
func WithShutdownTimeout ¶
WithShutdownTimeout returns an Option to set the timeout before the server shutdown abruptly
func WithStreamInterceptor ¶
func WithStreamInterceptor(streamInterceptor ...grpc.StreamServerInterceptor) Option
WithStreamInterceptor returns an Option to append some streamInterceptor
func WithUnaryInterceptor ¶
func WithUnaryInterceptor(unaryInterceptor ...grpc.UnaryServerInterceptor) Option
WithUnaryInterceptor returns an Option to append some unaryInterceptor