rabbitmq

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	GetCredentials() (string, string)
}

type Connection

type Connection interface {
	Ping(ctx context.Context) error
	Shutdown(ctx context.Context) error
}

Connection interface for handling rabbitmq connections.

type Consumer

type Consumer interface {
	Connection
	Consume(context.Context) error
}

Consumer interface used for defining a rabbitmq consumer. The Connection interface is embedded in this interface.

func NewConsumer

func NewConsumer(handler func(context.Context, amqp.Delivery) error, opts ...Option) (Consumer, error)

NewConsumer creates a new Consumer with an underlying Connection. The consumer is configurable through environment variables or by passing in an array of Option.

This method returns an error if the underlying connection fails to connect.

If no configuration is provided, a default connection is set up.

Pass an option WithAuthenticator to use a custom Authenticator.

type Option

type Option func(option)

Option is used in a functional options pattern to apply configuration options to the consumer and producer structs provided in this package.

func WithArgs

func WithArgs(args amqp.Table) Option

func WithAuthenticator

func WithAuthenticator(authenticator Authenticator) Option

func WithConsumerName

func WithConsumerName(name string) Option

func WithEndpoint

func WithEndpoint(endpoint string) Option

func WithExchangeName

func WithExchangeName(name string) Option

func WithExchangeType

func WithExchangeType(t string) Option

func WithLogger

func WithLogger(logger *slog.Logger) Option

func WithQueueName

func WithQueueName(name string) Option

func WithRoutingKey

func WithRoutingKey(key string) Option

type Publisher

type Publisher interface {
	Connection
	Publish(context.Context, amqp.Publishing) error
}

Publisher is an interface used for defining methods on a rabbitmq publisher. The Connection interface is embedded in this interface.

func NewPublisher

func NewPublisher(opts ...Option) Publisher

NewPublisher creates a new Publisher with an underlying Connection. The publisher is configurable through environment variables or by passing and array of Option.

This method returns an error if the underlying connection fails to connect.

If no configuration is provided, a default connection and publisher is set up.

Pass an option WithAuthenticator to use a custom Authenticator

Jump to

Keyboard shortcuts

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