subscriber

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exchange

type Exchange struct {
	// Name is the exchange name.
	Name string

	// Type is the exchange type. See ExchangeType for details.
	Type ExchangeType

	// IsDurable defines if is a durable queue.
	IsDurable bool

	// IsAutoDeleted defines if exchange is auto deleted.
	IsAutoDeleted bool

	// IsInternal defines if is a internal exchange.
	IsInternal bool

	// NoWait defines if is a noWait queue.
	NoWait bool

	// Args exchange creation args.
	Args map[string]interface{}

	// RoutingKey is the routingKey used to bind exchange to consumer queue (for topic exchanges).
	RoutingKey string
}

Exchange contains exchange settings.

type ExchangeType

type ExchangeType uint8

ExchangeType represents the RabbitMQ exchange type.

const (
	/*
		ExchangeTypeDirect represents a direct exchange type.

		This exchange type is the default and will forward package directly to a queue which is the same
		as the given routing key.
	*/
	ExchangeTypeDirect ExchangeType = iota

	/*
		ExchangeTypeFanout represents a fanout exchange type.

		When a message is published to a fanout exchange the message will be forwarded to all binded queues.
	*/
	ExchangeTypeFanout

	/*
		ExchangeTypeTopic represents a topic exchange type.

		When a message is published to this type of exchange the message will only be forwarded to
		binded queues that matches to the publishing routingKey.
	*/
	ExchangeTypeTopic

	/*
		ExchangeTypeHeaders represents a header exchange type.

		When a message is published to this type of exchange the message will only be forwarded to
		binded queues that matches to publishing headers.
	*/
	ExchangeTypeHeaders
)

func (ExchangeType) String

func (t ExchangeType) String() string

String returns the ExchangeType as string:

ExchangeTypeDirect  => "direct"
ExchangeTypeFanout  => "fanout"
ExchangeTypeTopic   => "topic"
ExchangeTypeHeaders => "headers"

func (ExchangeType) Value

func (t ExchangeType) Value() ExchangeType

Value check if exchange is valid, and if valid returns the current value otherwise returns 'direct' exchange as default

type Option

type Option func(s Subscriber)

Option is a subscriber option used to customize the consumer.

func WithDurableFanoutExchange

func WithDurableFanoutExchange(name string) Option

WithDurableFanoutExchange declare a fanout exchange an bind it to the consumer queue.

func WithDurablePriorityQueue

func WithDurablePriorityQueue(name string, maxPriority uint8) Option

WithDurablePriorityQueue defines a named durable queue for consumer with priority.

func WithDurableQueue

func WithDurableQueue(name string) Option

WithDurableQueue defines a named durable queue for consumer.

func WithDurableTopicExchange

func WithDurableTopicExchange(name, routingKey string) Option

WithDurableTopicExchange declare a topic exchange and bind it to the consumer queue.

func WithName

func WithName(name string) Option

WithName set consumer name.

func WithPrefetch

func WithPrefetch(count int) Option

WithPrefetch set prefetch count, and size.

type PrefetchQos

type PrefetchQos struct {
	Count    int
	Size     int
	IsGlobal bool
}

type Queue

type Queue struct {
	Name          string
	Durable       bool
	AutoDelete    bool
	Exclusive     bool
	NoWait        bool
	MaxPriority   uint8
	RoutingKey    string
	QueueBindArgs map[string]interface{}
}

func (*Queue) GetArgs

func (o *Queue) GetArgs() amqp.Table

type Subscriber

type Subscriber interface {
	pubsub.Subscriber
	AddExchange(exchange *Exchange)
	SetQueue(queue *Queue)
	SetName(name string)
	SetPrefetchQos(qos *PrefetchQos)
}

func NewSubscriber

func NewSubscriber(uri string, options ...Option) Subscriber

NewSubscriber creates a new RabbitMQ consumer.

Jump to

Keyboard shortcuts

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