Documentation
¶
Index ¶
- Constants
- Variables
- func GinMiddleware(opts ...optionGinFunc) gin.HandlerFunc
- func GrpcServerInterceptor(opts ...optionGrpcUnaryFunc) grpc.UnaryServerInterceptor
- func HttpMiddleware(next http.Handler) http.Handler
- func InjectHeaderCtx(ctx context.Context, _header interface{}, retry string)
- func NewRedisHook() redis.Hook
- func ParseHeader(hdr interface{}) (time.Duration, string, error)
- func SetDefaultGrpcOption(dop GrpcUnaryOption)
- func SetDefaultHttpOption(ho HttpOption)
- func SetLogger(logger Logger)
- func SetPrefixKey(pre string)
- func WithGinLeastQuota(quota time.Duration) optionGinFunc
- func WithGinResponse(header http.Header, obj interface{}) optionGinFunc
- func WithGrpcLeastQuota(quota time.Duration) optionGrpcUnaryFunc
- func WithGrpcResponse(header http.Header, obj interface{}) optionGrpcUnaryFunc
- type Entry
- type GrpcUnaryOption
- type HttpOption
- type Logger
- type Mapper
- type NullLogger
- type NullSpanContext
- type RedisHook
- func (hook RedisHook) AfterProcess(ctx context.Context, cmd redis.Cmder) error
- func (hook RedisHook) AfterProcessPipeline(ctx context.Context, cmds []redis.Cmder) error
- func (hook RedisHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (context.Context, error)
- func (hook RedisHook) BeforeProcessPipeline(ctx context.Context, cmds []redis.Cmder) (context.Context, error)
- type SpanContext
- func (sc *SpanContext) Cancel()
- func (sc *SpanContext) ContinueRetry() bool
- func (sc *SpanContext) GetCancel() context.CancelFunc
- func (sc *SpanContext) GetContext() context.Context
- func (sc *SpanContext) GetContextCancel() (context.Context, context.CancelFunc)
- func (sc *SpanContext) GetEntry() *Entry
- func (sc *SpanContext) GetGrpcMetadata(mds ...metadata.MD) metadata.MD
- func (sc *SpanContext) GetHttpHeader(hdrs ...http.Header) http.Header
- func (sc *SpanContext) InjectHeader(header interface{})
- func (sc *SpanContext) IsRetryON() bool
- func (sc *SpanContext) IsRetryOff() bool
- func (sc *SpanContext) IsRetryUnknown() bool
- func (sc *SpanContext) NotTimeout() bool
- func (sc *SpanContext) PromiseLeastQuota(quota time.Duration) bool
- func (sc *SpanContext) ReachTimeout() bool
Constants ¶
View Source
const ( RetryUnknown string = "unknown" RetryOn string = "on" RetryOff string = "off" )
Variables ¶
View Source
var ( ErrInvalidTimeout = errors.New("invalid timeout") ErrInvalidDeadline = errors.New("invalid deadline") ErrInvalidRetry = errors.New("invalid retry") )
View Source
var ( ErrHeaderRequestTimeout = errors.New("the timeout-ms value in header is 0, not enough time.") ErrRequestTimeout = errors.New("request timeout.") )
Functions ¶
func GinMiddleware ¶
func GinMiddleware(opts ...optionGinFunc) gin.HandlerFunc
GinMiddleware gin middleware
func GrpcServerInterceptor ¶
func GrpcServerInterceptor(opts ...optionGrpcUnaryFunc) grpc.UnaryServerInterceptor
GrpcServerInterceptor grpc server wrapper
func InjectHeaderCtx ¶
func NewRedisHook ¶
func NewRedisHook() redis.Hook
func SetDefaultHttpOption ¶
func SetDefaultHttpOption(ho HttpOption)
SetDefaultHttpOption the function call before app register middleware.
func SetPrefixKey ¶
func SetPrefixKey(pre string)
func WithGinLeastQuota ¶
func WithGinResponse ¶
func WithGrpcLeastQuota ¶
func WithGrpcResponse ¶
Types ¶
type GrpcUnaryOption ¶
type GrpcUnaryOption struct {
// contains filtered or unexported fields
}
type HttpOption ¶
type Mapper ¶
type Mapper struct {
// contains filtered or unexported fields
}
Mapper match with http.Header, grpc metadata.md, map[string]string, map[string]interface{}
type NullLogger ¶
type NullLogger struct{}
func (*NullLogger) Error ¶
func (l *NullLogger) Error(msg string)
type NullSpanContext ¶
type NullSpanContext struct {
// contains filtered or unexported fields
}
func (*NullSpanContext) Cancel ¶
func (sc *NullSpanContext) Cancel() bool
func (*NullSpanContext) GetGrpcMetadata ¶
func (sc *NullSpanContext) GetGrpcMetadata(mds ...metadata.MD) metadata.MD
func (*NullSpanContext) GetHttpMetadata ¶
func (sc *NullSpanContext) GetHttpMetadata(hdrs ...http.Header) http.Header
func (*NullSpanContext) NotTimeout ¶
func (sc *NullSpanContext) NotTimeout() bool
func (*NullSpanContext) ReachTimeout ¶
func (sc *NullSpanContext) ReachTimeout() bool
type RedisHook ¶
type RedisHook struct{}
func (RedisHook) AfterProcess ¶
func (RedisHook) AfterProcessPipeline ¶
func (RedisHook) BeforeProcess ¶
type SpanContext ¶
type SpanContext struct { TimeExists bool Deadline time.Time Timeout time.Duration RetryFlag string // contains filtered or unexported fields }
SpanContext
func NewSpanContext ¶
NewSpanContext
func ParseSpanFromCtx ¶
func ParseSpanFromCtx(ctx context.Context) (*SpanContext, error)
ParseSpanFromCtx
func ParseSpanFromHeader ¶
func ParseSpanFromHeader(ctx context.Context, header interface{}) (*SpanContext, error)
ParseSpanFromHeader header type is in the range of http.header, grpc.metadata and map.
func (*SpanContext) GetContextCancel ¶
func (sc *SpanContext) GetContextCancel() (context.Context, context.CancelFunc)
GetContextCancel
func (*SpanContext) GetEntry ¶
func (sc *SpanContext) GetEntry() *Entry
GetEntry get entry structure
func (*SpanContext) GetGrpcMetadata ¶
func (sc *SpanContext) GetGrpcMetadata(mds ...metadata.MD) metadata.MD
GetGrpcMetadata inject infector'args to header, then return the header.
func (*SpanContext) GetHttpHeader ¶
func (sc *SpanContext) GetHttpHeader(hdrs ...http.Header) http.Header
GetHttpHeader inject infector'args to header, then return the header. if don't input custom header, new header.
func (*SpanContext) InjectHeader ¶
func (sc *SpanContext) InjectHeader(header interface{})
InjectHeader
func (*SpanContext) PromiseLeastQuota ¶
func (sc *SpanContext) PromiseLeastQuota(quota time.Duration) bool
PromiseLeastQuota
Click to show internal directories.
Click to hide internal directories.