Documentation
¶
Index ¶
- func AppendToTopic(key, str string) string
- func StartConsumer[T any](r *RabbitConnector, consumer Consumer[T]) error
- func StartNotifier[T any](r *RabbitConnector, notifier Notifier[T]) error
- type Channel
- type Consumer
- type ConsumerOptions
- type Msg
- type NotificationOptions
- type Notifier
- type Publisher
- type PublisherOptions
- type Queue
- type RabbitConnector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendToTopic ¶
func StartConsumer ¶ added in v0.6.1
func StartConsumer[T any](r *RabbitConnector, consumer Consumer[T]) error
StartConsumer makes the necessary declarations and bindings to start a consumer. It will spawn 2 goroutines to receive and process (with retries) messages.
Everything will be handle with the options declared in the `Consumer` method `Options`
func StartNotifier ¶ added in v0.7.1
func StartNotifier[T any](r *RabbitConnector, notifier Notifier[T]) error
StartNotifier initiates the `Notifier` that will run in a goroutine
Types ¶
type Channel ¶ added in v0.8.6
type Channel struct {
// contains filtered or unexported fields
}
Wraps an amqp.Channel to handle reconnects
type Consumer ¶
type Consumer[T any] interface { Options() ConsumerOptions HandleMessage(T) error }
Consumer represents a RabbitMQ consumer for a typed `T` message
type ConsumerOptions ¶
type ConsumerOptions struct {
Exchange string
Topic string
QueueName string
// contains filtered or unexported fields
}
ConsumerOptions represents a queue binding for a Consumer
func NewConsumerOptions ¶ added in v0.5.2
func NewConsumerOptions(exchange, topic, queue string) ConsumerOptions
NewConsumerOptions creates a ConsumerOptions object with default configurations
func (ConsumerOptions) HasRetry ¶ added in v0.5.0
func (co ConsumerOptions) HasRetry() bool
func (ConsumerOptions) SetDurable ¶ added in v0.8.1
func (co ConsumerOptions) SetDurable() ConsumerOptions
SetDurable configures the queue to be persist if the consumer disconnects
func (ConsumerOptions) SetName ¶ added in v0.8.5
func (co ConsumerOptions) SetName(name string) ConsumerOptions
SetName sets the consumer name
func (ConsumerOptions) WithRetry ¶ added in v0.5.0
func (co ConsumerOptions) WithRetry(retries int, interval time.Duration) ConsumerOptions
WithRetry enables in memory retries of unhandled messages. It will retry `retries` times waiting `interval` each time.
type Msg ¶ added in v0.8.4
type Msg[T any] struct { // contains filtered or unexported fields }
Msg holds a RabbitMQ Delivery content's (after parse) alonside any attacked state needed. ex: number of retries
func (Msg[T]) Retry ¶ added in v0.8.5
Retry increases inner counter and sleeps before sending itself back through msgs. Use a goroutine!
func (Msg[T]) ShouldRetry ¶ added in v0.8.5
ShouldRetry reports if a msg can still be retried
type NotificationOptions ¶
NotificationOptions represents the behaviour of the `Notifier`
type Notifier ¶
type Notifier[T any] interface { Options() NotificationOptions Stop() bool Notify() (T, error) }
Notifier is a `Publisher` that publish on a regular interval
type Publisher ¶
type Publisher[T any] struct { // contains filtered or unexported fields }
Publisher represents a specific msg that can be published
func CreatePublisher ¶ added in v0.7.1
func CreatePublisher[T any](r *RabbitConnector, options PublisherOptions) (*Publisher[T], error)
CreatePublisher creates a `Publisher`
type PublisherOptions ¶
PublisherOptions specifies where a Publisher will publish messages
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
func (*Queue[T]) DequeueNoWait ¶ added in v0.5.1
func (q *Queue[T]) DequeueNoWait() *T
type RabbitConnector ¶
type RabbitConnector struct {
// contains filtered or unexported fields
}
func NewConnector ¶
func NewConnector(logger *zap.Logger) *RabbitConnector
func (*RabbitConnector) Channel ¶
func (rc *RabbitConnector) Channel() (*Channel, error)
func (*RabbitConnector) Connect ¶
func (rc *RabbitConnector) Connect(url string) error
func (RabbitConnector) Disconnect ¶
func (rc RabbitConnector) Disconnect() error