amqp

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Connection          ConnectionConfig
	Exchange            string
	Queue               string
	RoutingKey          string
	Prefetch            int
	ReconnectionTimeout time.Duration
	RepublishTimeout    time.Duration
	AMQPConfig          *amqp.Config
	Logger              *log.Logger
}

type ConnectionConfig

type ConnectionConfig struct {
	Host        string
	User        string
	Password    string
	VirtualHost string
	Port        int
}

func (*ConnectionConfig) Raw

func (c *ConnectionConfig) Raw() string

func (*ConnectionConfig) String

func (c *ConnectionConfig) String() string

type Worker

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

Worker is a RabbtiMQ consumer and publisher. It will setup an AMQP channel to consume messages from an exchange through a queue and will withstand disconnects on connection to RabbtiMQ.

Reconnection is implemented as a chan *connection that is consumed in the Start method. If connection loss is detected the reconnector Go routine will setup a new connection and push it on to the channel thus keeping Start blocking.

func NewWorker

func NewWorker(c Config) (*Worker, error)

NewWorker allocates and returns a Worker consuming and publising messages on an AMQP exchange.

func (*Worker) Close

func (s *Worker) Close() error

func (*Worker) Publish

func (s *Worker) Publish(ctx context.Context, event broker.Publishable) error

Publish publishes a message on a configured AMQP exchange.

func (*Worker) StartConsumer

func (s *Worker) StartConsumer(handlers map[string]func([]byte) error, errorHandler func(msgType string, msgBody []byte, err error)) error

StartConsumer starts the consumer on the worker. The method is blocking and will only return if the worker is stopped with Close.

Jump to

Keyboard shortcuts

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