Documentation
¶
Index ¶
- Variables
- type Hook
- func (w *Hook) ClientBatchPublish(next client.FuncBatchPublish) client.FuncBatchPublish
- func (w *Hook) ClientCall(next client.FuncCall) client.FuncCall
- func (w *Hook) ClientPublish(next client.FuncPublish) client.FuncPublish
- func (w *Hook) ClientStream(next client.FuncStream) client.FuncStream
- func (w *Hook) ServerHandler(next server.FuncHandler) server.FuncHandler
- func (w *Hook) ServerSubscriber(next server.FuncSubHandler) server.FuncSubHandler
- type XRequestIDKey
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultMetadataFunc = func(ctx context.Context) (context.Context, error) { var xid string cid, cok := ctx.Value(XRequestIDKey{}).(string) if cok && cid != "" { xid = cid } imd, iok := metadata.FromIncomingContext(ctx) if !iok || imd == nil { imd = metadata.New(1) ctx = metadata.NewIncomingContext(ctx, imd) } omd, ook := metadata.FromOutgoingContext(ctx) if !ook || omd == nil { omd = metadata.New(1) ctx = metadata.NewOutgoingContext(ctx, omd) } if xid == "" { var id string if id, iok = imd.Get(DefaultMetadataKey); iok && id != "" { xid = id } if id, ook = omd.Get(DefaultMetadataKey); ook && id != "" { xid = id } } if xid == "" { var err error xid, err = id.New() if err != nil { return ctx, err } } if !cok { ctx = context.WithValue(ctx, XRequestIDKey{}, xid) } if !iok { imd.Set(DefaultMetadataKey, xid) } if !ook { omd.Set(DefaultMetadataKey, xid) } return ctx, nil }
DefaultMetadataFunc wil be used if user not provide own func to fill metadata
View Source
var DefaultMetadataKey = textproto.CanonicalMIMEHeaderKey("x-request-id")
DefaultMetadataKey contains metadata key
View Source
var Wrapper = &Hook{}
Functions ¶
This section is empty.
Types ¶
type Hook ¶ added in v3.9.0
type Hook struct{}
func (*Hook) ClientBatchPublish ¶ added in v3.9.0
func (w *Hook) ClientBatchPublish(next client.FuncBatchPublish) client.FuncBatchPublish
func (*Hook) ClientCall ¶ added in v3.9.0
func (*Hook) ClientPublish ¶ added in v3.9.0
func (w *Hook) ClientPublish(next client.FuncPublish) client.FuncPublish
func (*Hook) ClientStream ¶ added in v3.9.0
func (w *Hook) ClientStream(next client.FuncStream) client.FuncStream
func (*Hook) ServerHandler ¶ added in v3.9.0
func (w *Hook) ServerHandler(next server.FuncHandler) server.FuncHandler
func (*Hook) ServerSubscriber ¶ added in v3.9.0
func (w *Hook) ServerSubscriber(next server.FuncSubHandler) server.FuncSubHandler
type XRequestIDKey ¶ added in v3.8.3
type XRequestIDKey struct{}
Click to show internal directories.
Click to hide internal directories.