rabbit

package
v0.0.0-...-1cbd5cf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PublishInChannel

func PublishInChannel(ch *amqp.Channel, exch, rKey string, message []byte) error

PublishInChannel publishes a message to a Rabbit exchange using a provided channel. For use in go routines.

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 GetConn

func GetConn(rabbitURL string) (*Conn, error)

GetConn established a Rabbit connection.

func (*Conn) Close

func (conn *Conn) Close() error

Close closes the Rabbit connection. All resources associated with the connection, including channels, will also be closed.

func (*Conn) DeclareTopicExchange

func (conn *Conn) DeclareTopicExchange(name string) error

DeclareTopicExchange declares an exchange of type 'topic'.

func (Conn) Publish

func (conn Conn) Publish(exch, rKey string, message []byte) error

Publish publishes a message to a Rabbit exchange using the main channel. For use in the main go routine.

func (*Conn) StartConsumer

func (conn *Conn) StartConsumer(exch, qName, rKey string, handler func(amqp.Delivery) bool) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL