Documentation ¶
Index ¶
- func PublishInChannel(ch *amqp.Channel, exch, rKey string, message []byte) error
- type Conn
- func (conn *Conn) Close() error
- func (conn *Conn) DeclareTopicExchange(name string) error
- func (conn Conn) Publish(exch, rKey string, message []byte) error
- func (conn *Conn) StartConsumer(exch, qName, rKey string, handler func(amqp.Delivery) bool) error
- func (conn *Conn) StartConsumerTemp(ctx context.Context, done chan<- bool, exch, rKey string, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Conn ¶
type Conn struct { Connection *amqp.Connection Channel *amqp.Channel }
Conn returns a Rabbit connecton. Also, a channel to be used in the main go routine.
func (*Conn) Close ¶
Close closes the Rabbit connection. All resources associated with the connection, including channels, will also be closed.
func (*Conn) DeclareTopicExchange ¶
DeclareTopicExchange declares an exchange of type 'topic'.
func (Conn) Publish ¶
Publish publishes a message to a Rabbit exchange using the main channel. For use in the main go routine.
func (*Conn) StartConsumer ¶
StartConsumer consumes messages from a Rabbit queue with a specified routing key and passes them to a supplied handler for processing. The queue is created (or connected to, if exists) and bound to an exchange. Used for durable queues in the main go routine.
func (*Conn) StartConsumerTemp ¶
func (conn *Conn) StartConsumerTemp(ctx context.Context, done chan<- bool, exch, rKey string, handler func(amqp.Delivery) error) error
StartConsumerTemp consumes messages with a specified routing key and passes them to a supplied handler for processing. Creates a separate channel and a temporary queue that will be deleted when processing ends (i.e. Websocket connection closes). Used in go routines such as each Websocket handler established by a front end user.