Documentation ¶
Index ¶
- func DecodeIDMessage(deliveryBody []byte) (uint, error)
- func EncodeIDMessage(id uint) []byte
- func EncodeStringIDMessage(id string) []byte
- type Client
- func (c *Client) CancelConsumer(consumerTag string) error
- func (c *Client) Connect() (err error)
- func (c *Client) Consume(queueName string, routingKey string) (<-chan amqp.Delivery, string, error)
- func (c *Client) Disconnect() error
- func (c *Client) PublishID(routingKey string, id uint) error
- func (c *Client) PublishStringID(routingKey string, id string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeIDMessage ¶
DecodeIDMessage decode a json object of the form `{"id": id}` where the id must be uint.
func EncodeIDMessage ¶
EncodeIDMessage encode the id into a json object of the form `{"id": id}`.
func EncodeStringIDMessage ¶
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 ¶
NewClient creates a new Client initialized with the given AMQP URI and durable Topic Exchange name.
func (*Client) CancelConsumer ¶
Cancel stops deliveries to the consumer.
func (*Client) Connect ¶
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) Disconnect ¶
Disconnect closes the RabbitMQ channel and connection.