Documentation ¶
Index ¶
- func AccessLog(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (interface{}, error)
- func ClientInterceptor(tracer opentracing.Tracer) grpc.UnaryClientInterceptor
- func ClientTracing() grpc.UnaryClientInterceptor
- func ErrorLog(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (interface{}, error)
- func Recovery(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (interface{}, error)
- func ServerInterceptor(tracer opentracing.Tracer) grpc.UnaryServerInterceptor
- func StreamContextTimeout() grpc.StreamClientInterceptor
- func UnaryContextTimeout() grpc.UnaryClientInterceptor
- type MDCarrier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccessLog ¶
func AccessLog(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
func ClientInterceptor ¶
func ClientInterceptor(tracer opentracing.Tracer) grpc.UnaryClientInterceptor
ClientInterceptor 客户端拦截器 https://godoc.org/google.golang.org/grpc#UnaryClientInterceptor
func ClientTracing ¶
func ClientTracing() grpc.UnaryClientInterceptor
ClientInterceptor grpc client wrapper
func ErrorLog ¶
func ErrorLog(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
普通错误记录的日志拦截器
func Recovery ¶
func Recovery(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
异常捕抓拦截器
func ServerInterceptor ¶
func ServerInterceptor(tracer opentracing.Tracer) grpc.UnaryServerInterceptor
ServerInterceptor Server 端的拦截器
func StreamContextTimeout ¶
func StreamContextTimeout() grpc.StreamClientInterceptor
func UnaryContextTimeout ¶
func UnaryContextTimeout() grpc.UnaryClientInterceptor
Types ¶
type MDCarrier ¶
MDCarrier custome carrier
func (MDCarrier) ForeachKey ¶
ForeachKey conforms to the TextMapReader interface. 这里必须要实现这个 TextMapReader 这个接口 TextMapReader is the Extract() carrier for the TextMap builtin format. With it, the caller can decode a propagated SpanContext as entries in a map of unicode strings.
type TextMapReader interface { // ForeachKey returns TextMap contents via repeated calls to the `handler` // function. If any call to `handler` returns a non-nil error, ForeachKey // terminates and returns that error. // // NOTE: The backing store for the TextMapReader may contain data unrelated // to SpanContext. As such, Inject() and Extract() implementations that // call the TextMapWriter and TextMapReader interfaces must agree on a // prefix or other convention to distinguish their own key:value pairs. // // The "foreach" callback pattern reduces unnecessary copying in some cases // and also allows implementations to hold locks while the map is read. ForeachKey(handler func(key, val string) error) error }
func (MDCarrier) Set ¶
Set implements Set() of opentracing.TextMapWriter 这里也必须要实现 TextMapWriter is the Inject() carrier for the TextMap builtin format. With it, the caller can encode a SpanContext for propagation as entries in a map of unicode strings.
type TextMapWriter interface { // Set a key:value pair to the carrier. Multiple calls to Set() for the // same key leads to undefined behavior. // // NOTE: The backing store for the TextMapWriter may contain data unrelated // to SpanContext. As such, Inject() and Extract() implementations that // call the TextMapWriter and TextMapReader interfaces must agree on a // prefix or other convention to distinguish their own key:value pairs. Set(key, val string) }