Documentation ¶
Index ¶
- func AreHeadersInitialized(ctx context.Context) bool
- func ContextWithHeaders(ctx context.Context, headersSetters ...HeaderSetter) (context.Context, error)
- func GetASCIIHeaderByName(ctx context.Context, name string) (string, error)
- func GetAnyBinaryHeader(ctx context.Context, destination proto.Message) error
- func GetAnyBinaryHeaderByName(ctx context.Context, destination proto.Message, name string) error
- func GetHeader(ctx context.Context, destination proto.Message) error
- func GetHeaderByName(ctx context.Context, destination proto.Message, name string) error
- func GetPropagatingHeader(ctx context.Context, destination proto.Message) error
- func GetRootHeader(ctx context.Context, destination proto.Message) error
- func GetRootHeaderByName(ctx context.Context, destination proto.Message, name string) error
- func GetStringHeaderByName(ctx context.Context, name string) (string, error)
- func SetASCIIHeader(ctx context.Context, name string, data string) error
- func SetHeader(ctx context.Context, data proto.Message) error
- func SetHeaderByName(ctx context.Context, data proto.Message, name string) error
- func SetPropagatingHeader(ctx context.Context, data proto.Message) error
- func StreamClientInterceptor() grpc.StreamClientInterceptor
- func StreamServerInterceptor() grpc.StreamServerInterceptor
- func UnaryClientInterceptor() grpc.UnaryClientInterceptor
- func UnaryServerInterceptor() grpc.UnaryServerInterceptor
- type HeaderKey
- type HeaderSetter
- type Headers
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AreHeadersInitialized ¶
AreHeadersInitialized determines whether headers have been initialized for the provided context. We assume headers are always initialized via ContextWithHeaders.
func ContextWithHeaders ¶
func ContextWithHeaders(ctx context.Context, headersSetters ...HeaderSetter) (context.Context, error)
ContextWithHeaders creates a new context with predefined headerPrefixes. Needed when starting from a fresh context, as they will not come with the Header keys needed to send the header to the next service.
func GetASCIIHeaderByName ¶
GetStringHeaderByName takes the inbound header and returns the data, if it is a string. If no header exists or the header value is not a string, an empty string will be returned.
func GetAnyBinaryHeader ¶
GetAnyBinaryHeader will try to find the header by checking all the binary headers, in the following order.
1. GetRootHeader() 2. GetHeader() 3. GetPropagatingHeader()
Note, it is not recommended to to use this method to retrieve headers, as it may induce some ambiguity. For example, XiUUid may have a different meaning in each Type.
func GetAnyBinaryHeaderByName ¶
GetAnyBinaryHeaderByName will try to find the header by checking all the binary headers, in the following order.
1. GetRootHeader() 2. GetHeader() 3. GetPropagatingHeader()
Note, it is not recommended to to use this method to retrieve headers, as it may induce some ambiguity. For example, XiUUid may have a different meaning in each Type.
func GetHeader ¶
GetHeader takes the inbound header and unmarshal the data into the destination message. If no header exists, destination will have all default values.
func GetHeaderByName ¶
GetHeaderByName takes the inbound header and unmarshal the data into the destination messaging. If no header exists, destination will have all default values.
func GetPropagatingHeader ¶
GetPropagatingHeader takes the propagating header and unmarshal the data into the destination message. If no header exists, destination will have all default values
func GetRootHeader ¶
GetRootHeader takes the root header and unmarshal the data into the destination message. If no header exists, destination will have all default values.
func GetRootHeaderByName ¶
GetRootHeaderByName takes the root header and unmarshal the data into the destination message. If no header exists, destination will have all default values.
func GetStringHeaderByName ¶
GetStringHeaderByName takes the inbound header and returns the data, if it is a string. If no header exists or the header value is not a string, an empty string will be returned.
func SetASCIIHeader ¶
SetASCIIHeader sets an ASCII header in the given context.
func SetHeaderByName ¶
SetHeaderByName sets the outbound header in the given context.
func SetPropagatingHeader ¶
SetPropagatingHeader sets the propagating header in the given context.
func StreamClientInterceptor ¶
func StreamClientInterceptor() grpc.StreamClientInterceptor
StreamClientInterceptor sends all the headers in the current context to a server stream
func StreamServerInterceptor ¶
func StreamServerInterceptor() grpc.StreamServerInterceptor
StreamServerInterceptor returns a grpc.StreamServerInterceptor that takes all the appropriate headerPrefixes from the metadata and puts it into the context of the streamWrapper
func UnaryClientInterceptor ¶
func UnaryClientInterceptor() grpc.UnaryClientInterceptor
UnaryClientInterceptor sends all the headers in the current context to server
func UnaryServerInterceptor ¶
func UnaryServerInterceptor() grpc.UnaryServerInterceptor
UnaryServerInterceptor returns a grpc.UnaryServerInterceptor that takes all the appropriate headerPrefixes from the metadata and puts it into the context
Types ¶
type HeaderKey ¶
type HeaderKey string
HeaderKey is the key to store all the header information in the context
type HeaderSetter ¶
HeaderSetter a pair of a headerSetterFunc and the proto header to set. It is meant to be used with ContextWithHeaders to create a new context with all the proper Header information.
func DefaultHeaderSetter ¶
func DefaultHeaderSetter(namedProto proto.Message) HeaderSetter
DefaultHeaderSetter returns a HeaderSetter using the SetHeader and the namedProto passed in as the Data.
func PropagatingHeaderSetter ¶
func PropagatingHeaderSetter(namedProto proto.Message) HeaderSetter
PropagatingHeaderSetter returns a HeaderSetter using SetPropagatingHeader and the namedProto passed in as the Data.
type Headers ¶
type Headers map[string]interface{}
Headers a custom map that takes a string as a key and either a string or []byte as its value
type Type ¶
type Type int
Type represents the header type
const ( // Outbound headers are only sent on the next service call. They are received as Inbound headers // on the recipients side. Outbound Type = iota // Inbound headers are received from the previous service call, and will not be sent to future service calls Inbound // Root headers are created from edge layers, and will be passed on to all future service calls Root // Propagating headers can be created by anyone, and will be passed on to all future service calls Propagating // ASCII headers are similar to Inbound headers, except the header is pure text and not an encoded protobuf ASCII )