Documentation ¶
Index ¶
- func PackDeadline(ctx context.Context, msg *amqp.Publishing) (bool, error)
- func PackSpanContext(ctx context.Context, msg *amqp.Publishing) error
- func PackTrace(msg *amqp.Publishing, traceID string)
- func UnpackDeadline(parent context.Context, msg *amqp.Delivery) (context.Context, func())
- func UnpackSpanContext(msg *amqp.Delivery, t opentracing.Tracer) (opentracing.SpanContext, error)
- func UnpackTrace(parent context.Context, msg *amqp.Delivery) context.Context
- type ChannelPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PackDeadline ¶
PackDeadline uses deadline information from ctx to populate the expiration field of msg. The return value is true if a deadline is present.
The context "done" error is returned if the deadline has already passed or the context has been canceled.
func PackSpanContext ¶
func PackSpanContext(ctx context.Context, msg *amqp.Publishing) error
PackSpanContext packs a serialized "span context" into the headers of msg based on the span in ctx, if any.
func PackTrace ¶
func PackTrace(msg *amqp.Publishing, traceID string)
PackTrace sets msg.CorrelationId to traceID, only if it differs to msgID.
The AMQP correlation ID field is used to tie "root" requests (be they command requests or notifications) to any requests that are made in response to that "root" request. This is different to the popular use of the correlation ID field, which is often used to relate a response to a request.
func UnpackDeadline ¶
UnpackDeadline creates a new context based on parent which has a deadline computed from the expiration information in msg.
The return values are the same as context.WithDeadline()
func UnpackSpanContext ¶
func UnpackSpanContext(msg *amqp.Delivery, t opentracing.Tracer) (opentracing.SpanContext, error)
UnpackSpanContext extracts a span context from the headers of msg. If no span context is packed in the headers, nil is returned.
func UnpackTrace ¶
UnpackTrace creates a new context with a trace ID based on the AMQP correlation ID from msg.
If the correlation ID is empty, the message is considered a "root" request, so the message ID is used as the correlation ID.
Types ¶
type ChannelPool ¶
type ChannelPool interface { // Get fetches a channel from the pool, or creates one as necessary. Get() (*amqp.Channel, error) // GetQOS fetches a channel from the pool and sets the pre-fetch count // before returning it. The pre-fetch is applied to across all consumers on // the channel. GetQOS(preFetch uint) (*amqp.Channel, error) // Put returns a channel to the pool. Put(*amqp.Channel) }
ChannelPool provides a pool of reusable AMQP channels.
func NewChannelPool ¶
func NewChannelPool(broker *amqp.Connection, size uint) ChannelPool
NewChannelPool returns a channel pool of the given size.