publisher

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel added in v0.5.2

type Channel interface {
	PublishWithContext(ctx context.Context, exchange, key string, mandatory, immediate bool, msg amqp.Publishing) error
}

Channel is a RabbitMQ channel for publishing.

func Wrap added in v0.5.2

func Wrap(channel Channel, mws ...Middleware) Channel

Wrap channel with middlewares.

type ChannelFunc added in v0.5.2

type ChannelFunc func(ctx context.Context, exchange, key string, mandatory, immediate bool, msg amqp.Publishing) error

ChannelFunc type is an adapter to allow the use of ordinary functions as Channel.

func (ChannelFunc) PublishWithContext added in v0.5.2

func (f ChannelFunc) PublishWithContext(ctx context.Context, exchange, key string, mandatory, immediate bool, msg amqp.Publishing) error

PublishWithContext implements Channel.

type Middleware added in v0.5.2

type Middleware func(Channel) Channel

Middleware adds new functionality for publishing.

func WithExpiration

func WithExpiration(expire time.Duration) Middleware

WithExpiration sets publishing Expire property.

func WithHeaders added in v0.5.2

func WithHeaders(table amqp.Table) Middleware

WithHeaders adds headers to the published message.

func WithImmediate

func WithImmediate() Middleware

WithImmediate sets server to discard a message when no consumer on the matched queue is ready to accept the delivery and server will return an undeliverable message with a Return method. See https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.publish.immediate.

func WithMandatory

func WithMandatory() Middleware

WithMandatory sets server to discard a message if no queue is bound that matches the routing key and server will return an undeliverable message with a Return method. See https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.publish.mandatory.

func WithTransientDeliveryMode

func WithTransientDeliveryMode() Middleware

WithTransientDeliveryMode sets publishing to the Transient delivery mode. Transient means higher throughput but messages will not be restored on broker restart. See https://github.com/rabbitmq/amqp091-go/blob/main/types.go#L123.

type Publisher

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

Publisher is a Publisher to RabbiMQ.

func New

func New(channel Channel, exchange string, mws ...Middleware) Publisher

New creates new RabbitMQ Publisher. By default, it will publish with Persistent delivery mode, mandatory=false, immediate=false and empty args. Pass Options to configure it as you wish.

func (Publisher) Publish

func (p Publisher) Publish(ctx context.Context, key string, message []byte, mws ...Middleware) error

Publish message with routing key. Allows to override middleware for one publishing.

Jump to

Keyboard shortcuts

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