amqp

package
v0.0.0-...-6647630 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AMQP_API           = utils.Getenv("AMQP_API", "amqp://telemetry:telemetry@localhost:5672/")
	AMQP_NAME_QUEUE    = utils.Getenv("AMQP_NAME_QUEUE", "go-logger-packets")
	AMQP_BINDING_KEY   = utils.Getenv("AMQP_BINDING_KEY", "")
	AMQP_CONSUMER_TAG  = utils.Getenv("AMQP_CONSUMER_TAG", "")
	AMQP_EXCHANGE_LIST = utils.Getenv("AMQP_EXCHANGE_LIST", "demo1, demo2")
	AMQP_EXCHANGE_TYPE = utils.Getenv("AMQP_EXCHANGE_TYPE", "headers")

	CONSUMER = &Consumer{}
)

Functions

func Listen

func Listen()

Types

type Consumer

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

Consumer holds all information about the RabbitMQ connection This setup does limit a consumer to one exchange. This should not be an issue. Having to connect to multiple exchanges means something else is structured improperly.

func NewConsumer

func NewConsumer(uri, changes, exchangeType, queueName, bindingKey, consumerTag string) *Consumer

func (*Consumer) AnnounceQueue

func (c *Consumer) AnnounceQueue(queueName string) (<-chan amqp.Delivery, error)

AnnounceQueue sets the queue that will be listened to for this connection...

func (*Consumer) Connect

func (c *Consumer) Connect() error

func (*Consumer) Handle

func (c *Consumer) Handle(
	deliveries <-chan amqp.Delivery,
	fn func(<-chan amqp.Delivery, chan []byte),
	queue string,
	packetCh chan []byte)

Handle has all the logic to make sure your program keeps running d should be a delievey channel as created when you call AnnounceQueue fn should be a function that handles the processing of deliveries this should be the last thing called in main as code under it will become unreachable unless put int a goroutine. The q and rk params are redundant but allow you to have multiple queue listeners in main without them you would be tied into only using one queue per connection

func (*Consumer) ReConnect

func (c *Consumer) ReConnect(queueName string) (<-chan amqp.Delivery, error)

ReConnect is called in places where NotifyClose() channel is called wait 30 seconds before trying to reconnect. Any shorter amount of time will likely destroy the error log while waiting for servers to come back online. This requires two parameters which is just to satisfy the AccounceQueue call and allows greater flexability

func (*Consumer) Shutdown

func (c *Consumer) Shutdown() error

Jump to

Keyboard shortcuts

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