consumer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2019 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNilConsumerQueue returned error when consumer queue is Nil
	ErrNilConsumerQueue = fmt.Errorf("Nil Consumer Queue")
)

Functions

func DeliveryGetBody

func DeliveryGetBody(d *amqp.Delivery) interface{}

DeliveryGetBody is a Helper that just return the body of the delively as a string

func DeliveryLogHandler

func DeliveryLogHandler(d *amqp.Delivery) interface{}

DeliveryLogHandler is an Helper to log the delivery

Types

type Consumer

type Consumer struct {
	Config     *amqpconfig.Config
	Queue      *amqp.Queue
	OutputChan chan interface{}
	// contains filtered or unexported fields
}

Consumer structure

func NewConsumer

func NewConsumer(config *amqpconfig.Config, q *Queue) (c Consumer, err error)

NewConsumer creates a new consumer not using TLS

func (*Consumer) Abort

func (c *Consumer) Abort()

Abort tells the conusmer to stop consuming

func (*Consumer) Bind

func (c *Consumer) Bind(e Exchange) error

Bind binds the queue of the Consumer to the exchange

func (*Consumer) Consume

func (c *Consumer) Consume(f func(*amqp.Delivery) interface{}, expectResult bool) error

Consume function consumes for any queue from the consumer

func (*Consumer) Flush

func (c *Consumer) Flush()

Flush the OutputChan of the conusmer to prevent deadlocks

func (*Consumer) SetArgs

func (c *Consumer) SetArgs(args amqp.Table)

SetArgs args setter

func (*Consumer) SetExclusive

func (c *Consumer) SetExclusive(excl bool)

SetExclusive exclusive setter

func (*Consumer) SetNoAck

func (c *Consumer) SetNoAck(noAck bool)

SetNoAck noAck setter

func (*Consumer) SetNoLocal

func (c *Consumer) SetNoLocal(noloc bool)

SetNoLocal noLocal setter

func (*Consumer) SetNoWait

func (c *Consumer) SetNoWait(noWait bool)

SetNoWait noWait setter

func (*Consumer) SetQueue

func (c *Consumer) SetQueue(q *Queue) error

SetQueue helps to split up the code to set the queue of the consumer

func (*Consumer) SetTag

func (c *Consumer) SetTag(tag string)

SetTag tag setter

func (*Consumer) SetWorkers

func (c *Consumer) SetWorkers(workers int)

SetWorkers sets the number of concurrent workers

func (*Consumer) Shutdown

func (c *Consumer) Shutdown(flush bool) error

Shutdown function

func (*Consumer) Wait

func (c *Consumer) Wait()

Wait the workers of the consumer

func (*Consumer) Work

func (c *Consumer) Work(workerID int, deliveries <-chan amqp.Delivery, f func(d *amqp.Delivery) interface{}, expectResult bool)

Work processes the deliveries one by one by applying function f on each

type Exchange

type Exchange struct {
	Name       string
	Type       string
	Durable    bool
	AutoDelete bool
	Internal   bool
	NoWait     bool
	Args       amqp.Table
	//NumQueues   int
	QueueConfig Queue
}

Exchange structure

func TemporaryExchange

func TemporaryExchange(name, eType string) (e Exchange)

TemporaryExchange initialize a temporary exchange

func (*Exchange) String

func (e *Exchange) String() string

String implementation

type Queue

type Queue struct {
	Name       string
	Durable    bool
	AutoDelete bool
	Exclusive  bool
	NoWait     bool
	Args       amqp.Table
}

Queue structure

func TemporaryQueue

func TemporaryQueue(name string) Queue

TemporaryQueue helper to create a temporary queue

Jump to

Keyboard shortcuts

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