listener

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSinkAlreadyClosed = errors.New("listener.Sink: already closed")

ErrSinkAlreadyClosed is returned by listener.Sink when attempting to close the returned Closer more than once.

Functions

This section is empty.

Types

type Channel

type Channel interface {
	io.Closer

	Qos(prefetchCount, prefetchSize int, global bool) error
	Consume(queue, name string, autoAck, exclusive, noLocal, noWait bool, args amqp.Table) (<-chan amqp.Delivery, error)
}

Channel is the channel interface the Listener uses to listen and serve incoming messages.

type Closer

type Closer interface {
	Close(context.Context) error
	Closed() <-chan error
}

Closer is used to stop listening from a specific Listener.

type Connection

type Connection interface {
	io.Closer

	Channel() (*amqp.Channel, error)
}

Connection is the connection interface the Listener uses to listen and serve incoming messages.

type Func

type Func func(Connection, Channel, handler.Handler) (Closer, error)

Func is an inline function that implements the Listener interface. Useful for mocking or stateless Listener implementations.

func (Func) Listen

func (fn Func) Listen(conn Connection, ch Channel, h handler.Handler) (Closer, error)

Listen executes the inline function.

type Listener

type Listener interface {
	Listen(Connection, Channel, handler.Handler) (Closer, error)
}

Listener listens for incoming messages using an amqp.Connection or amqp.Channel provided, and calls the specified message handler to handle all incoming messages.

Returns a Closer interface to stop listening to incoming messages.

func Sink

func Sink(listeners ...Listener) Listener

Sink allows for listening from multiple Listeners, by maintaining an amqp.Delivery sink to which all the messages are sent.

Returns nil if no listeners are supplied.

func UseDedicatedChannel

func UseDedicatedChannel(listener Listener) Listener

UseDedicatedChannel creates a new, dedicated amqp.Channel to be used exclusively by the wrapped Listener.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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