Documentation
¶
Index ¶
- type BindingOptions
- type Closer
- type Config
- type Consumer
- type ConsumerOptions
- type Exchange
- type Producer
- type PublishingOptions
- type Queue
- type RabbitMQ
- func (r *RabbitMQ) Conn() *amqp.Connection
- func (r *RabbitMQ) Connect() (*RabbitMQ, error)
- func (r *RabbitMQ) Dial() error
- func (r *RabbitMQ) NewConsumer(e Exchange, q Queue, bo BindingOptions, co ConsumerOptions) (*Consumer, error)
- func (r *RabbitMQ) NewProducer(e Exchange, q Queue, po PublishingOptions) (*Producer, error)
- func (r *RabbitMQ) RegisterSignalHandler()
- func (r *RabbitMQ) Shutdown() error
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BindingOptions ¶
type BindingOptions struct {
// Publishings messages to given Queue with matching -RoutingKey-
// Every Queue has a default binding to Default Exchange with their Qeueu name
// So you can send messages to a queue over default exchange
RoutingKey string
// Do not wait for a consumer
NoWait bool
// App specific data
Args amqp.Table
}
type Closer ¶
type Closer interface {
RegisterSignalHandler()
Shutdown() error
}
Closer interface is for handling reconnection logic in a sane way Every reconnection supported struct should implement those methods in order to work properly
type Consumer ¶
type Consumer struct {
// Base struct for Producer
*RabbitMQ
// contains filtered or unexported fields
}
func (*Consumer) Consume ¶
Consume accepts a handler function for every message streamed from RabbitMq will be called within this handler func
func (*Consumer) Deliveries ¶
func (*Consumer) Get ¶
ConsumeMessage accepts a handler function and only consumes one message stream from RabbitMq
type ConsumerOptions ¶
type ConsumerOptions struct {
// The consumer is identified by a string that is unique and scoped for all
// consumers on this channel.
Tag string
// When autoAck (also known as noAck) is true, the server will acknowledge
// deliveries to this consumer prior to writing the delivery to the network. When
// autoAck is true, the consumer should not call Delivery.Ack
AutoAck bool // autoAck
// Check Queue struct documentation
Exclusive bool // exclusive
// When noLocal is true, the server will not deliver publishing sent from the same
// connection to this consumer. (Do not use Publish and Consume from same channel)
NoLocal bool // noLocal
// Check Queue struct documentation
NoWait bool // noWait
// Check Exchange comments for Args
Args amqp.Table // arguments
}
type Exchange ¶
type Exchange struct {
// Exchange name
Name string
// Exchange type
Type string
// Durable exchanges will survive server restarts
Durable bool
// Will remain declared when there are no remaining bindings.
AutoDelete bool
// Exchanges declared as `internal` do not accept accept publishings.Internal
// exchanges are useful for when you wish to implement inter-exchange topologies
// that should not be exposed to users of the broker.
Internal bool
// When noWait is true, declare without waiting for a confirmation from the server.
NoWait bool
// amqp.Table of arguments that are specific to the server's implementation of
// the exchange can be sent for exchange types that require extra parameters.
Args amqp.Table
}
type Producer ¶
type Producer struct {
// Base struct for Producer
*RabbitMQ
// contains filtered or unexported fields
}
func (*Producer) NotifyReturn ¶
NotifyReturn captures a message when a Publishing is unable to be delivered either due to the `mandatory` flag set and no route found, or `immediate` flag set and no free consumer.
type PublishingOptions ¶
type PublishingOptions struct {
// The key that when publishing a message to a exchange/queue will be only delivered to
// given routing key listeners
RoutingKey string
// Publishing tag
Tag string
// Queue should be on the server/broker
Mandatory bool
// Consumer should be bound to server
Immediate bool
}
type Queue ¶
type Queue struct {
// The queue name may be empty, in which the server will generate a unique name
// which will be returned in the Name field of Queue struct.
Name string
// Check Exchange comments for durable
Durable bool
// Check Exchange comments for autodelete
AutoDelete bool
// Exclusive queues are only accessible by the connection that declares them and
// will be deleted when the connection closes. Channels on other connections
// will receive an error when attempting declare, bind, consume, purge or delete a
// queue with the same name.
Exclusive bool
// When noWait is true, the queue will assume to be declared on the server. A
// channel exception will arrive if the conditions are met for existing queues
// or attempting to modify an existing queue from a different connection.
NoWait bool
// Check Exchange comments for Args
Args amqp.Table
}
type RabbitMQ ¶
type RabbitMQ struct {
// contains filtered or unexported fields
}
func (*RabbitMQ) Connect ¶
Connect opens a connection to RabbitMq. This function is idempotent
TODO this should not return RabbitMQ struct - cihangir,arslan config changes
func (*RabbitMQ) NewConsumer ¶
func (r *RabbitMQ) NewConsumer(e Exchange, q Queue, bo BindingOptions, co ConsumerOptions) (*Consumer, error)
NewConsumer is a constructor for consumer creation Accepts Exchange, Queue, BindingOptions and ConsumerOptions
func (*RabbitMQ) NewProducer ¶
NewProducer is a constructor function for producer creation Accepts Exchange, Queue, PublishingOptions. On the other hand we are not declaring our topology on both the publisher and consumer to be able to change the settings only in one place. We can declare those settings on both place to ensure they are same. But this package will not support it.
func (*RabbitMQ) RegisterSignalHandler ¶
func (r *RabbitMQ) RegisterSignalHandler()
RegisterSignalHandler watchs for interrupt signals and gracefully closes connection
type Session ¶
type Session struct {
// Exchange declaration settings
Exchange Exchange
// Queue declaration settings
Queue Queue
// Binding options for current exchange to queue binding
BindingOptions BindingOptions
// Consumer options for a queue or exchange
ConsumerOptions ConsumerOptions
// Publishing options for a queue or exchange
PublishingOptions PublishingOptions
}
Session is holding the current Exchange, Queue, Binding Consuming and Publishing settings for enclosed rabbitmq connection