amqp

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExchangePublisher

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

ExchangePublisher is a service for publishing messages to an exchange

func NewExchangePublisher

func NewExchangePublisher(amqpURL string) *ExchangePublisher

NewExchangePublisher creates a Publisher

func (*ExchangePublisher) EnsurePublisherIsReady

func (p *ExchangePublisher) EnsurePublisherIsReady() error

EnsurePublisherIsReady ensures that the publisher is ready to send messages

func (*ExchangePublisher) Publish

func (p *ExchangePublisher) Publish(exchangeName string, headers map[string]string, body []byte) error

Publish publishes a message to the given exchange

func (*ExchangePublisher) PublishWithRoutingKey added in v2.3.1

func (p *ExchangePublisher) PublishWithRoutingKey(exchangeName string, routingKey string, body []byte) error

PublishWithRoutingKey publishes a message to the given exchange, with a routing key to specify the queue

type ExchangeSubscription

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

ExchangeSubscription is a service for subscribing to an AMQP exchange

func NewExchangeSubscription

func NewExchangeSubscription(amqpURL string, exchangeName string) *ExchangeSubscription

NewExchangeSubscription creates a new ExchangeSubscription

func (*ExchangeSubscription) Consume

func (es *ExchangeSubscription) Consume(outerCtx context.Context) (<-chan *Message, error)

Consume starts consuming messages

Any messages that are not explicitly Acked or Nacked by this consumer before the connection is terminated will be automatically requeued.

func (*ExchangeSubscription) EnsureExchangeSubscriptionIsReady

func (es *ExchangeSubscription) EnsureExchangeSubscriptionIsReady() error

EnsureExchangeSubscriptionIsReady ensures that the necessary transient queue exists and is bound to the exchange

func (*ExchangeSubscription) ExchangeName

func (es *ExchangeSubscription) ExchangeName() string

ExchangeName is the name of the exchange to which this is subscribed

type Message

type Message struct {
	// Headers are the collection of metadata passed along with the Body
	Headers map[string]interface{}
	// Body is the unmodified byte array containing the message
	Body []byte
	// Ack acknowledges the successful processing of the message
	Ack func() error
	// Nack acknowledges the failed processing of the message and instructs the message to be requeued
	Nack func() error
}

Message represents a message in-flight from an AMQP broker

Jump to

Keyboard shortcuts

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