Documentation ¶
Overview ¶
Package thrift provides a Thrift binding for endpoints.
Index ¶
- func ContextWithResponseMeta(ctx context.Context, v *Metadata) context.Context
- func ExtractResponseMeta(next thrift.TClient) thrift.TClient
- type ClientFinalizerFunc
- type ClientRequestFunc
- type ClientResponseFunc
- type Header
- type HeaderContext
- type HeaderMap
- type Metadata
- type ServerFinalizerFunc
- type ServerRequestFunc
- type ServerResponseFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithResponseMeta ¶
ContextWithResponseMeta returns a copy of ctx with v set as the response metadata value.
func ExtractResponseMeta ¶
ExtractResponseMeta is a Thrift middleware that retrieves the Thrift response metadata and injects it into the context. This is useful for passing along metadata from the Thrift response to other parts of the application that have access to the context.
Types ¶
type ClientFinalizerFunc ¶
ClientFinalizerFunc can be used to perform work at the end of a client Thrift request, after the response is returned. The principal intended use is for error logging. Additional response parameters are provided in the context under keys with the ContextKeyResponse prefix. NOTE: err may be nil. There maybe also no additional response parameters depending on when an error occurs.
type ClientRequestFunc ¶
ClientRequestFunc may take information from context and use it to construct headers to be transported to the server. ClientRequestFuncs are executed after creating the request but prior to sending the Thrift request to the server.
func SetRequestHeader ¶
func SetRequestHeader(key, val string) ClientRequestFunc
SetRequestHeader returns a ClientRequestFunc that sets the specified header key-value pair.
type ClientResponseFunc ¶
ClientResponseFunc may take information from a Thrift response metadata and make the responses available for consumption. ClientResponseFuncs are only executed in clients, after a request has been made, but prior to it being decoded.
type Header ¶
type Header interface { // Get returns the value associated with the given key. If the key is // present in the header, the value (which may be empty) is returned. // Otherwise, the returned value will be the empty string. The ok return // value reports whether the value is explicitly set in the header. Get(key string) (value string, ok bool) // Set sets the header entry associated with key to the value. Set(key, value string) // Keys returns the keys of the header. Keys() []string }
Header contains methods for managing Thrift headers.
type HeaderContext ¶
type HeaderContext struct {
// contains filtered or unexported fields
}
HeaderContext represents a Thrift header backed by a context.
func NewHeaderContext ¶
func NewHeaderContext(ctx context.Context) *HeaderContext
NewHeaderContext creates and returns a new instance of HeaderContext with provider context.
func (*HeaderContext) Get ¶
func (h *HeaderContext) Get(key string) (string, bool)
Get returns the value associated with the given key. If the key is present in the header, the value (which may be empty) is returned. Otherwise, the returned value will be the empty string. The ok return value reports whether the value is explicitly set in the header.
func (*HeaderContext) Keys ¶
func (h *HeaderContext) Keys() []string
Keys returns a slice containing all the keys present in the context's headers.
func (*HeaderContext) Set ¶
func (h *HeaderContext) Set(string, string)
Set is a no-op method for HeaderContext, implementing the Header interface. NOTE: Cannot set to HeaderContext.
type HeaderMap ¶
HeaderMap represents a Thrift header backed by a map.
type Metadata ¶
type Metadata struct { // The headers in the request or response. Header Header }
Metadata represents the metadata attached to the request or response.
func ResponseMetaFromContext ¶
ResponseMetaFromContext returns the response metadata from ctx.
type ServerFinalizerFunc ¶
ServerFinalizerFunc can be used to perform work at the end of an gRPC request, after the response has been written to the client.
type ServerRequestFunc ¶
ServerRequestFunc may extracts information from the request context and associates it with a new user-defined key. ServerRequestFunc allows for unified access these data in service or endpoint middleware, similar to other transport types (such as gRPC, HTTP, ...). ServerRequestFuncs are executed prior to invoking the endpoint.
func SetRequestContext ¶
func SetRequestContext(ctxKey any, headerKey string) ServerRequestFunc
SetRequestContext returns a ServerRequestFunc that associates a value from the request context with a new user-defined key.
type ServerResponseFunc ¶
ServerResponseFunc may take information from a request context and use it to manipulate the gRPC response metadata headers and trailers. ResponseFuncs are only executed in servers, after invoking the endpoint but prior to writing a response.