Documentation
¶
Index ¶
- type Authenticator
- type Connection
- type Consumer
- type Option
- func WithArgs(args amqp.Table) Option
- func WithAuthenticator(authenticator Authenticator) Option
- func WithConsumerName(name string) Option
- func WithEndpoint(endpoint string) Option
- func WithExchangeName(name string) Option
- func WithExchangeType(t string) Option
- func WithLogger(logger *slog.Logger) Option
- func WithQueueName(name string) Option
- func WithRoutingKey(key string) Option
- type Publisher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Connection ¶
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 WithAuthenticator ¶
func WithAuthenticator(authenticator Authenticator) Option
func WithConsumerName ¶
func WithEndpoint ¶
func WithExchangeName ¶
func WithExchangeType ¶
func WithLogger ¶
func WithQueueName ¶
func WithRoutingKey ¶
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 ¶
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