rabbitmq

package
v0.0.0-...-46d964f Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2020 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Package rabbitmq implements the triton-core/amqp module

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorEnsureExchange is returned when exchanges are unable to be created
	ErrorEnsureExchange = errors.New("failed to ensure exchange")

	// ErrorEnsureConsumerQueues is returned when consumer queues are unable to be created
	ErrorEnsureConsumerQueues = errors.New("failed to ensure consumer queues")
)

Functions

This section is empty.

Types

type Client

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

Client is a RabbitMQ client

func NewClient

func NewClient(endpoint string) (*Client, error)

NewClient returns a new rabbitmq client

func (*Client) Channel

func (c *Client) Channel() (*amqp.Channel, error)

Channel returns a raw RabbitMQ channel

func (*Client) Consume

func (c *Client) Consume(topic string) (<-chan *Delivery, error)

Consume from a RabbitMQ queue

func (*Client) Publish

func (c *Client) Publish(topic string, body []byte) error

Publish a message to an exchange, must be a serialized format

func (*Client) SetPrefetch

func (c *Client) SetPrefetch(prefetch int64)

SetPrefetch updates the prefetch of our channels

type Delivery

type Delivery struct {
	Metadata DeliveryMetadata

	// Delivery is the internal amqp delivery struct
	Delivery amqp.Delivery

	// Channel this message was recieved on
	Channel *amqp.Channel
}

Delivery is an AMQP delivery

func NewDelivery

func NewDelivery(delivery amqp.Delivery, channel *amqp.Channel) (*Delivery, error)

NewDelivery creates a delivery object

func (*Delivery) Ack

func (d *Delivery) Ack() error

Ack acks the message

func (*Delivery) Error

func (d *Delivery) Error() error

Error reports an error with a message and reschedules it for a retry TODO(jaredallard): use deadletter queues

func (*Delivery) Nack

func (d *Delivery) Nack() error

Nack dequeues the message

type DeliveryMetadata

type DeliveryMetadata struct {
	Retries int
}

DeliveryMetadata is metadata from AMQP headers

Jump to

Keyboard shortcuts

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