Documentation
¶
Index ¶
Constants ¶
View Source
const DEFAULT_MAX_RECONNECT_TIMES = 3
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsumerConfig ¶ added in v0.2.0
type ProducerConfig ¶ added in v0.2.0
type RabbitInterface ¶
type RabbitInterface interface {
// Connect creates a new connection and returns RabbitInterface to access functions and error
Connect() (RabbitInterface, error)
// GetConnect gets the active connection
GetConnect() *rbm_pool
// SimpleQueueDeclare used to declare a single Queue into RabbitMQ and returns it or an error
SimpleQueueDeclare(sq Queue) (queue amqp.Queue, err error)
// CompleteQueueDeclare used to declare a multiple Queue into RabbitMQ and returns a list of errors if happens.
//
// NOTE: If you run this function defining the Bind field contained in Queue, you must have to had defined
// an Exchange first and then passing it to the field.
CompleteQueueDeclare(sq []Queue) []error
// SimpleExchangeDeclare used to declare a single Exchange into RabbitMQ and returns an error if happens
SimpleExchangeDeclare(se Exchange) error
// CompleteExchangeDeclare used to declare a multiple Exchange into RabbitMQ and returns a list of errors if happens
CompleteExchangeDeclare(ce []Exchange) []error
// CompleteDeclare used to fully declare multiple Queue and Exchange into
// RabbitMQ and returns a list of errors if happens.
//
// NOTE: You can pass empty arrays to this function if not present in your project. If your project
// doesn't contain binds, just don't set the Bind field contained in Queue struct.
CompleteDeclare(cq []Queue, ce []Exchange) []error
// Producer publishes a Message to RabbitMQ following the configuration passed on ProducerConfig
Producer(ctx context.Context, pc *ProducerConfig, msg *Message) error
// Consumer consumes a Queue on RabbitMQ following the configuration passed on ConsumerConfig
Consumer(cc *ConsumerConfig, callback func(msg *amqp.Delivery))
// StartConsumer starts a consumer routine listening to a Queue of RabbitMQ
// following the configuration passed on ConsumerConfig.
//
// There is a DEFAULT_MAX_RECONNECT_TIMES variable that defines on 3 the number of retries to reconnect to the
// RabbitMQ service currently running. You can define this number by setting an env variable called
// SRV_RMQ_MAXX_RECONNECT_TIMES
StartConsumer(cc *ConsumerConfig, callback func(msg *amqp.Delivery))
}
func New ¶ added in v0.1.1
func New(conf *config.Config) RabbitInterface
Click to show internal directories.
Click to hide internal directories.