Documentation ¶
Index ¶
Constants ¶
View Source
const (
DefaultTagsPrefix = "fx-tags"
)
Variables ¶
View Source
var ( ErrMalformedTags = errors.New("grpctags: Failed to marshal/unmarshal tags") ErrInvalidCarrier = errors.New("grpctags: Invalid Inject/Extract carrier") ErrInvalidTagsVal = errors.New("grpctags: Invalid tagsVal") ErrTagsValNull = errors.New("grpctags: tagsVal is string null") )
View Source
var (
NoopTags = &noopTags{}
)
Functions ¶
func UnaryClientInterceptor ¶
func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor
UnaryClientInterceptor returns a new unary server interceptor for OpenTracing.
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor
UnaryServerInterceptor returns a new unary server interceptors that sets the values for request tags.
Types ¶
type Tags ¶
type Tags interface { // Set sets the given key in the metadata tags. Set(key string, value interface{}) Tags // Has checks if the given key exists. Has(key string) bool // Get returns value of given key Get(key string) interface{} // Values returns a map of key to values. // Do not modify the underlying map, please use Set instead. Values() map[string]interface{} // Foreach some kind like visitor pattern , each element pair will call f func // and if accept return with error , the whole Foreach will return error // it some kind like each implementation in ruby https://ruby-doc.org/core-2.7.2/Hash.html#method-i-each //todo, require to review the necessary of Foreach to return error Foreach(f func(key string, val interface{}) error) error Len() int }
Tags is the interface used for storing request tags between Context calls. The default implementation is *not* thread safe, and should be handled only in the context of the request.
func FromContext ¶
FromContext returns a pre-existing Tags object in the Context. If the context wasn't set in a tag interceptor, a no-op Tag storage is returned that will *not* be propagated in context.
Click to show internal directories.
Click to hide internal directories.