rabbitmq

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2021 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeIDMessage

func DecodeIDMessage(deliveryBody []byte) (uint, error)

DecodeIDMessage decode a json object of the form `{"id": id}` where the id must be uint.

func EncodeIDMessage

func EncodeIDMessage(id uint) []byte

EncodeIDMessage encode the id into a json object of the form `{"id": id}`.

func EncodeStringIDMessage

func EncodeStringIDMessage(id string) []byte

EncodeStringIDMessage encode the id into a json object of the form `{"id": id}`.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides a simple interface for connecting to RabbitMQ, declaring a channel, and declaring a durable Topic Exchange, which is used by various pub/sub operations all along the program.

func NewClient

func NewClient(amqpURI, exchangeName string) *Client

NewClient creates a new Client initialized with the given AMQP URI and durable Topic Exchange name.

func (*Client) CancelConsumer

func (c *Client) CancelConsumer(consumerTag string) error

CancelConsumer stops deliveries to the consumer.

func (*Client) Connect

func (c *Client) Connect() (err error)

Connect opens a new RabbitMQ connection to the Client's AMQP URI, then it opens a unique server channel and uses it to declare a durable Topic Exchange using the Client's Exchange name.

When you are done using the client, remember to call Client.Disconnect to disconnect and free the resources.

func (*Client) Consume

func (c *Client) Consume(queueName string, routingKey string) (<-chan amqp.Delivery, string, error)

Consume immediately starts delivering queued messages.

func (*Client) Disconnect

func (c *Client) Disconnect() error

Disconnect closes the RabbitMQ channel and connection.

func (*Client) PublishID

func (c *Client) PublishID(routingKey string, id uint) error

PublishID publishes a new persistent message using the given routing key; the message consists in a JSON object containing given ID.

func (*Client) PublishStringID

func (c *Client) PublishStringID(routingKey string, id string) error

PublishStringID publishes a new persistent message using the given routing key; the message consists in a JSON object containing given string ID.

Jump to

Keyboard shortcuts

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