Documentation ¶
Index ¶
- Constants
- func CloneContext(parent context.Context) (cloned context.Context)
- func ContextWithFrame(parent context.Context) (ctx context.Context)
- func ContextWithFrameOf(parent context.Context, x any) (ctx context.Context)
- type Frame
- func (f Frame) Baggage(name string) string
- func (f Frame) CallDepth() int
- func (f Frame) ClockShift() time.Duration
- func (f Frame) Fragment() (index int, max int)
- func (f Frame) FromHost() string
- func (f Frame) FromID() string
- func (f Frame) FromVersion() int
- func (f Frame) Get(name string) string
- func (f Frame) Header() http.Header
- func (f Frame) Languages() []string
- func (f Frame) Locality() string
- func (f Frame) MessageID() string
- func (f Frame) OpCode() string
- func (f Frame) Queue() string
- func (f Frame) Set(name string, value string)
- func (f Frame) SetBaggage(name string, value string)
- func (f Frame) SetCallDepth(depth int)
- func (f Frame) SetClockShift(offset time.Duration)
- func (f Frame) SetFragment(index int, max int)
- func (f Frame) SetFromHost(host string)
- func (f Frame) SetFromID(id string)
- func (f Frame) SetFromVersion(version int)
- func (f Frame) SetLanguages(language ...string)
- func (f Frame) SetLocality(locality string)
- func (f Frame) SetMessageID(id string)
- func (f Frame) SetOpCode(op string)
- func (f Frame) SetQueue(queue string)
- func (f Frame) SetTimeBudget(budget time.Duration)
- func (f Frame) TimeBudget() time.Duration
- func (f Frame) XForwardedBaseURL() string
- func (f Frame) XForwardedFullURL() string
Constants ¶
const ( HeaderPrefix = "Microbus-" HeaderBaggagePrefix = HeaderPrefix + "Baggage-" HeaderMsgId = HeaderPrefix + "Msg-Id" HeaderFromHost = HeaderPrefix + "From-Host" HeaderFromId = HeaderPrefix + "From-Id" HeaderFromVersion = HeaderPrefix + "From-Version" HeaderTimeBudget = HeaderPrefix + "Time-Budget" HeaderCallDepth = HeaderPrefix + "Call-Depth" HeaderOpCode = HeaderPrefix + "Op-Code" HeaderQueue = HeaderPrefix + "Queue" HeaderFragment = HeaderPrefix + "Fragment" HeaderClockShift = HeaderPrefix + "Clock-Shift" HeaderLocality = HeaderPrefix + "Locality" OpCodeError = "Err" OpCodeAck = "Ack" OpCodeRequest = "Req" OpCodeResponse = "Res" )
Variables ¶
This section is empty.
Functions ¶
func CloneContext ¶
CloneContext returns a new context with a copy of the frame of the parent context, or a new frame if it does not have one. Manipulating the frame of the cloned context does not impact the parent's.
func ContextWithFrame ¶
ContextWithFrame adds a new empty frame to the context. If the parent includes a frame, it will be superseded by the given frame.
func ContextWithFrameOf ¶
ContextWithFrameOf returns a new context derived from the parent, referencing the frame of x. If the parent includes a frame, it will be superseded by the given frame. Manipulating the frame of the new context impacts the original frame.
Types ¶
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
Frame is a utility class that helps with manipulating the control headers.
func Of ¶
Of creates a new frame wrapping the headers of the HTTP request, response, response writer, header, or context.
func (Frame) Baggage ¶
Baggage is an arbitrary header that is passed through to downstream microservices.
func (Frame) CallDepth ¶
CallDepth is the depth of the call stack beginning at the original request.
func (Frame) ClockShift ¶
ClockShift returns the time offset set in the frame. Time offsets are used during testing to offset the clock of a transaction. A positive offset moves the clock into the future. A negative offset moves the clock into the past.
func (Frame) Fragment ¶
Fragment returns the index of the fragment of large messages out of the total number of fragments. Fragments are indexed starting at 1.
func (Frame) FromHost ¶
FromHost is the hostname of the microservice that made the request or response.
func (Frame) FromID ¶
FromID is the unique ID of the instance of the microservice that made the request or response.
func (Frame) FromVersion ¶
FromVersion is the version number of the microservice that made the request or response.
func (Frame) Languages ¶
Languages parses the Accept-Language header and returns the listed languages in order of their q value.
func (Frame) Locality ¶
Locality indicates the geographic locality of the microservice that handled the request. It is used by the client to optimize routing of unicast requests.
func (Frame) Queue ¶
Queue indicates the queue of the subscription that handled the request. It is used by the client to optimize multicast requests.
func (Frame) SetBaggage ¶
SetBaggage sets an arbitrary header that is passed through to downstream microservices.
func (Frame) SetCallDepth ¶
SetCallDepth sets the depth of the call stack beginning at the original request.
func (Frame) SetClockShift ¶
SetClockShift sets the time offset in the frame. Time offsets are used during testing to offset the clock of a transaction. A positive offset moves the clock into the future. A negative offset moves the clock into the past.
func (Frame) SetFragment ¶
Fragment sets the index of the fragment of large messages out of the total number of fragments. Fragments are indexed starting at 1.
func (Frame) SetFromHost ¶
SetFromHost sets the hostname of the microservice that is making the request or response.
func (Frame) SetFromID ¶
SetFromID sets the unique ID of the instance of the microservice that is making the request or response.
func (Frame) SetFromVersion ¶
SetFromVersion sets the version number of the microservice that is making the request or response.
func (Frame) SetLanguages ¶
SetLanguages sets the Accept-Language header with the list of languages.
func (Frame) SetLocality ¶
SetLocality sets the geographic locality of the microservice that handled the request. It is used by the client to optimize routing of unicast requests.
func (Frame) SetMessageID ¶
SetMessageID sets the unique ID given to each HTTP message or response.
func (Frame) SetQueue ¶
SetQueue sets the queue of the subscription that handled the request. It is used by the client to optimize multicast requests.
func (Frame) SetTimeBudget ¶
SetTimeBudget budgets a duration for the request to complete. A value of 0 indicates no time budget.
func (Frame) TimeBudget ¶
TimeBudget is the duration budgeted for the request to complete. A value of 0 indicates no time budget.
func (Frame) XForwardedBaseURL ¶
XForwardedBaseURL returns the amalgamated headers X-Forwarded-Proto, -Host and -Prefix, without a trailing slash. The empty string is returned if the headers are not present.
func (Frame) XForwardedFullURL ¶
XForwardedFullURL returns the amalgamated headers X-Forwarded-Proto, -Host, -Prefix and -Path, without a trailing slash. The empty string is returned if the headers are not present.