Documentation ¶
Overview ¶
Package rabbitmq has all the functions to make it work. Check the README for more details
Index ¶
- func KeepConnectionAndSetup(ctx context.Context, conn Connector, config ConfigConnection, ...)
- func NotifyOpenConnection(notify chan struct{})
- func NotifySetupDone(notify chan struct{})
- type Closer
- type ConfigBindQueue
- type ConfigConnection
- type ConfigConsume
- type ConfigExchange
- type ConfigPublish
- type ConfigQueue
- type Connector
- type Consumer
- type ExchangeCreator
- type Publisher
- type QueueBinder
- type QueueCreator
- type RabbitMQ
- type RabbitSetup
- type Setup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KeepConnectionAndSetup ¶ added in v0.0.3
func KeepConnectionAndSetup(ctx context.Context, conn Connector, config ConfigConnection, setupRabbit RabbitSetup)
KeepConnectionAndSetup starts a goroutine to keep the connection open and everytime the connection is open, it will call the setupRabbit function. It is important to pass a context with cancel so the goroutine can be closed when the context is done. Otherwise it will run until the program ends.
func NotifyOpenConnection ¶ added in v0.0.3
func NotifyOpenConnection(notify chan struct{})
NotifyOpenConnection registers a channel to be notified when the connection is open
func NotifySetupDone ¶ added in v0.0.3
func NotifySetupDone(notify chan struct{})
NotifySetupDone registers a channel to be notified when the setup is done by the KeepConnectionAndSetup function
Types ¶
type ConfigBindQueue ¶
type ConfigBindQueue struct { QueueName string Exchange string RoutingKey string NoWait bool Args amqp.Table }
ConfigBindQueue is the configuration for the bind to queue
type ConfigConnection ¶
ConfigConnection is the configuration for the connection
type ConfigConsume ¶
type ConfigConsume struct { QueueName string Consumer string AutoAck bool Exclusive bool NoLocal bool NoWait bool Args amqp.Table ExecuteConcurrent bool }
ConfigConsume is the configuration for the consumer
func NewConfigConsume ¶ added in v0.0.5
func NewConfigConsume(queueName, consumer string) ConfigConsume
NewConfigConsume helper function to create a new ConfigConsume with some default values
type ConfigExchange ¶ added in v0.0.5
type ConfigExchange struct { Name string Type string Durable bool AutoDelete bool Internal bool NoWait bool Args amqp.Table }
ConfigExchange is the configuration for the exchange
type ConfigPublish ¶
type ConfigPublish struct { Exchange string RoutingKey string Mandatory bool Immediate bool Headers amqp.Table ContentType string ContentEncoding string Priority uint8 CorrelationID string MessageID string }
ConfigPublish is the configuration for the publisher
func NewConfigPublish ¶ added in v0.0.5
func NewConfigPublish(exchange, routingKey string) ConfigPublish
NewConfigPublish helper function to create a new ConfigPublish with some default values
type ConfigQueue ¶
type ConfigQueue struct { Name string Durable bool AutoDelete bool Exclusive bool NoWait bool Args amqp.Table }
ConfigQueue is the configuration for the queue
type Connector ¶
type Connector interface {
Connect(config ConfigConnection) (notify chan *amqp.Error, err error)
}
Connector is an interface for connecting to a RabbitMQ server
type Consumer ¶
type Consumer interface {
Consume(ctx context.Context, config ConfigConsume, f func(*amqp.Delivery)) (err error)
}
Consumer is the interface for consuming messages from a queue
type ExchangeCreator ¶ added in v0.0.5
type ExchangeCreator interface {
CreateExchange(config ConfigExchange) (err error)
}
ExchangeCreator is the interface for creating exchanges
type Publisher ¶
type Publisher interface {
Publish(ctx context.Context, body []byte, config ConfigPublish) (err error)
}
Publisher is the interface for publishing messages to an exchange
type QueueBinder ¶ added in v0.0.5
type QueueBinder interface { BindQueueExchange(config ConfigBindQueue) (err error) UnbindQueueExchange(config ConfigBindQueue) (err error) }
QueueBinder is the interface for binding and unbinding queues
type QueueCreator ¶
type QueueCreator interface {
CreateQueue(config ConfigQueue) (queue amqp.Queue, err error)
}
QueueCreator is the interface for creating
type RabbitMQ ¶
type RabbitMQ interface { Connector Closer QueueCreator QueueBinder ExchangeCreator Consumer Publisher }
RabbitMQ combines all the interfaces of the package
func NewRabbitMQ ¶
func NewRabbitMQ() RabbitMQ
NewRabbitMQ creates the object to manage the operations to rabbitMQ
type RabbitSetup ¶ added in v0.0.3
type RabbitSetup interface {
Setup()
}
RabbitSetup is the interface for setting up the RabbitMQ queues and exchanges after the connection is made