Documentation
¶
Overview ¶
Package rabbitmq implements a Celery broker using RabbitMQ and github.com/rabbitmq/amqp091-go.
Index ¶
Constants ¶
const DefaultAmqpUri = "amqp://guest:guest@localhost:5672/"
DefaultAmqpUri defines the default AMQP URI which is used to connect to RabbitMQ.
const DefaultReceiveTimeout = 5
DefaultReceiveTimeout defines how many seconds the broker's Receive command should block waiting for results from RabbitMQ.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Broker ¶
type Broker struct {
// contains filtered or unexported fields
}
Broker is a RabbitMQ broker that sends/receives messages from specified queues.
func NewBroker ¶
func NewBroker(options ...BrokerOption) (*Broker, error)
NewBroker creates a broker backed by RabbitMQ. By default, it connects to localhost.
func (*Broker) Observe ¶
Observe sets the queues from which the tasks should be received. Note, the method is not concurrency safe.
type BrokerOption ¶
type BrokerOption func(*Broker)
BrokerOption sets up a Broker.
func WithAmqpUri ¶
func WithAmqpUri(amqpUri string) BrokerOption
WithAmqpUri sets the AMQP connection URI to RabbitMQ.
func WithClient ¶
func WithClient(c *amqp.Connection) BrokerOption
WithClient sets RabbitMQ client representing a connection to RabbitMQ.
func WithReceiveTimeout ¶
func WithReceiveTimeout(timeout time.Duration) BrokerOption
WithReceiveTimeout sets a timeout of how long the broker's Receive command should block waiting for results from RabbitMQ. Larger the timeout, longer the client will have to wait for Celery app to exit. Smaller the timeout, more Get commands would have to be sent to RabbitMQ.