amqpx

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package amqpx holds the low-level AMQP plumbing shared by the publisher and consumer: connection dialing, exchange declaration, credential-safe URL masking, trace-context propagation, and the retry-count header. It is internal so the public API stays small and this layer can evolve freely.

Index

Constants

View Source
const RetryCountHeader = "x-retry-count"

RetryCountHeader is the message header tracking how many times a delivery has been retried in place.

Variables

This section is empty.

Functions

func DeclareExchange

func DeclareExchange(conn *amqp.Connection, name, kind string) error

DeclareExchange declares a durable exchange of the given kind on a temporary channel.

func Dial

func Dial(opts DialOptions) (*amqp.Connection, error)

Dial opens a new AMQP connection bounded by the dial and overall connection timeouts. The whole DialConfig call is raced against ConnectionTimeout so a stalled handshake cannot block startup indefinitely.

func MaskURL

func MaskURL(raw string) string

MaskURL replaces the password in an AMQP URL with "***" so the URL is safe to log. URLs without userinfo or without a password are returned unchanged.

func NextRetryHeaders

func NextRetryHeaders(original amqp.Table, count int) (amqp.Table, error)

NextRetryHeaders returns a copy of original with the retry counter set to count. It errors if count does not fit in the int32 AMQP header type.

func ReadRetryCount

func ReadRetryCount(headers amqp.Table) int

ReadRetryCount reads the retry counter from message headers, returning 0 when it is absent or of an unexpected type.

Types

type DialOptions

type DialOptions struct {
	URL string
	// TLSClientConfig enables TLS, custom CAs, or mTLS.
	TLSClientConfig *tls.Config
	// Heartbeat configures AMQP heartbeats. Leave zero for amqp091-go defaults.
	Heartbeat time.Duration
	// Locale configures the AMQP locale. Leave empty for amqp091-go defaults.
	Locale string
	// ClientProperties are sent during connection negotiation.
	ClientProperties amqp.Table
	// ConnectionName is sent as the RabbitMQ connection_name client property.
	ConnectionName string
	// SASL configures authentication mechanisms.
	SASL []amqp.Authentication
	// DialTimeout bounds the underlying TCP dial.
	DialTimeout time.Duration
	// ConnectionTimeout bounds the full AMQP handshake.
	ConnectionTimeout time.Duration
}

DialOptions configures Dial.

Jump to

Keyboard shortcuts

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