amqputil

package
v0.0.0-...-335d32b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PackDeadline

func PackDeadline(ctx context.Context, msg *amqp.Publishing) (bool, error)

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

func UnpackDeadline(parent context.Context, msg *amqp.Delivery) (context.Context, func())

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

func UnpackTrace(parent context.Context, msg *amqp.Delivery) context.Context

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL