autodlq

package module
v0.0.0-...-93aa1fd Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 License: MIT Imports: 1 Imported by: 0

README

Auto DLQ

This is a package I built while working on one of my article. I was trying things around and explore rabbitMQ. It depends on streadway/amqp.

autodlq.DeclareQ

It helps to declare a queue with its DLX in case you passed a config implementation with SupportDlq() bool that returns true.

autodlq.ConsumeQ

It helps decouple your infrastructure code from application. You are not supposed to worry about infrastructure things. You just need to have Consumer implementation with the desired behaviour you need on:

  • OnConsuming(d amqp.Delivery) error What functions should be invoked while handling your message.
  • OnConsumed(d amqp.Delivery) error What should happen after successfully consuming the message. Maybe some useful logs.
  • OnRetry(d amqp.Delivery) error How to retry the message.
  • OnMaxRetry(d amqp.Delivery) error What should happen when we reached the max retry.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConsumeQ

func ConsumeQ(channel *amqp.Channel, consumer Consumer, config ConsumeConfig, errChan chan<- error) error

func DeclareQ

func DeclareQ(channel *amqp.Channel, c DeclareConfig) error

Types

type ConsumeConfig

type ConsumeConfig interface {
	QueueName() string
	MaxRetryCount() uint64
}

type Consumer

type Consumer interface {
	OnConsuming(d amqp.Delivery) error
	OnConsumed(d amqp.Delivery) error
	OnRetry(d amqp.Delivery) error
	OnMaxRetry(d amqp.Delivery) error
}

type DeclareConfig

type DeclareConfig interface {
	QueueName() string
	DLQName() string
	RoutingKeyName() string
	ExchangeName() string
	DLXName() string
	MsgTTL() uint64
	SupportDlq() bool
}

Directories

Path Synopsis
_examples

Jump to

Keyboard shortcuts

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