amqp

package
v4.41.2 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: MIT Imports: 16 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoConfig = errors.New("URI is required")

ErrNoConfig occurs when URI is not provided

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Client wraps all object required for AMQP usage

func New

func New(config Config, prometheusRegister prometheus.Registerer) (*Client, error)

New inits AMQP connection from Config

func NewFromURI added in v4.28.3

func NewFromURI(uri string, prefetch int, prometheusRegister prometheus.Registerer) (*Client, error)

NewFromURI inits AMQP connection from given URI

func (*Client) Close

func (c *Client) Close()

Close closes opened ressources

func (*Client) Consumer

func (c *Client) Consumer(queueName, routingKey, exchangeName string, exclusive bool, dlExchange string) (err error)

Consumer configures client for consumming from given queue, bind to given exchange, and return delayed Exchange name to publish

func (*Client) DelayedExchange added in v4.30.1

func (c *Client) DelayedExchange(queueName, exchangeName, routingKey string, retryDelay time.Duration) (delayExchange string, err error)

DelayedExchange configures dead-letter exchange with given ttl

func (*Client) Enabled

func (c *Client) Enabled() bool

Enabled checks if connection is setup

func (*Client) Exclusive added in v4.29.5

func (c *Client) Exclusive(ctx context.Context, name string, timeout time.Duration, action func(context.Context) error) (acquired bool, err error)

Exclusive get an exclusive lock from given queue during duration

func (*Client) Listen

func (c *Client) Listen(queueResolver QueueResolver, exchange, routingKey string) (string, <-chan amqp.Delivery, error)

Listen listens to configured queue

func (*Client) Ping

func (c *Client) Ping() error

Ping checks if connection is live

func (*Client) Publish

func (c *Client) Publish(payload amqp.Publishing, exchange, routingKey string) error

Publish sends payload to the underlying exchange

func (*Client) PublishJSON added in v4.29.6

func (c *Client) PublishJSON(item any, exchange, routingKey string) error

PublishJSON sends JSON payload to the underlying exchange

func (*Client) Publisher

func (c *Client) Publisher(exchangeName, exchangeType string, args amqp.Table) (err error)

Publisher configures client for publishing to given exchange

func (*Client) SetupExclusive added in v4.29.5

func (c *Client) SetupExclusive(name string) (err error)

SetupExclusive configure the exclusive queue

func (*Client) StopListener added in v4.25.0

func (c *Client) StopListener(consumer string) (err error)

StopListener cancel consumer listening

func (*Client) Vhost

func (c *Client) Vhost() string

Vhost returns connection Vhost

type Config added in v4.28.2

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

Config of package

func Flags added in v4.28.2

func Flags(fs *flag.FlagSet, prefix string) Config

Flags adds flags for configuring package

type Connection

type Connection interface {
	io.Closer
	Channel() (*amqp.Channel, error)
	IsClosed() bool
}

Connection for AMQP

type QueueResolver added in v4.30.1

type QueueResolver func() (string, error)

QueueResolver return the name of the queue to listen

Jump to

Keyboard shortcuts

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