Documentation ¶
Index ¶
- func AppendToTopic(key, str string) string
- func StartConsumer[T any](r Connector, consumer Consumer[T]) error
- func StartNotifier[T any](r Connector, notifier Notifier[T]) error
- type AMQPChannel
- func (c *AMQPChannel) Ack(tag uint64, multiple bool)
- func (c *AMQPChannel) Close() error
- func (c *AMQPChannel) Consume(opts ConsumerOptions, outMsgs chan any) error
- func (c *AMQPChannel) Logger() Logger
- func (c *AMQPChannel) Publish(opts PublisherOptions, msg []byte) error
- func (c *AMQPChannel) Reject(tag uint64, requeue bool)
- type Channel
- type Connector
- type Consumer
- type ConsumerOptions
- type LogFunc
- type Logger
- type Msg
- type NotificationOptions
- type Notifier
- type PubSub
- type PubSubChannel
- 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
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`
Types ¶
type AMQPChannel ¶ added in v0.9.1
type AMQPChannel struct {
// contains filtered or unexported fields
}
Wraps an amqp.Channel to handle reconnects
func NewAMQPChannel ¶ added in v0.9.1
func NewAMQPChannel(conn *RabbitConnector) (*AMQPChannel, error)
func (*AMQPChannel) Ack ¶ added in v0.9.1
func (c *AMQPChannel) Ack(tag uint64, multiple bool)
func (*AMQPChannel) Close ¶ added in v0.9.4
func (c *AMQPChannel) Close() error
func (*AMQPChannel) Consume ¶ added in v0.9.1
func (c *AMQPChannel) Consume(opts ConsumerOptions, outMsgs chan any) error
func (*AMQPChannel) Logger ¶ added in v0.9.3
func (c *AMQPChannel) Logger() Logger
func (*AMQPChannel) Publish ¶ added in v0.9.1
func (c *AMQPChannel) Publish(opts PublisherOptions, msg []byte) error
func (*AMQPChannel) Reject ¶ added in v0.9.1
func (c *AMQPChannel) Reject(tag uint64, requeue bool)
type Connector ¶ added in v0.9.1
type Connector interface { Connect(string) error Disconnect() error Channel() (Channel, error) SetLogger(Logger) Logger() Logger }
func NewConnector ¶
func NewConnector() Connector
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.
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 PubSub ¶ added in v0.9.1
type PubSub struct {
// contains filtered or unexported fields
}
func (*PubSub) Disconnect ¶ added in v0.9.1
type PubSubChannel ¶ added in v0.9.1
type PubSubChannel struct {
// contains filtered or unexported fields
}
func (*PubSubChannel) Ack ¶ added in v0.9.1
func (p *PubSubChannel) Ack(uint64, bool)
func (*PubSubChannel) Consume ¶ added in v0.9.1
func (p *PubSubChannel) Consume(o ConsumerOptions, out chan any) error
func (*PubSubChannel) Logger ¶ added in v0.9.3
func (p *PubSubChannel) Logger() Logger
func (*PubSubChannel) Publish ¶ added in v0.9.1
func (p *PubSubChannel) Publish(o PublisherOptions, data []byte) error
func (*PubSubChannel) Reject ¶ added in v0.9.1
func (p *PubSubChannel) Reject(uint64, bool)
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 Connector, 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 (*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
func (*RabbitConnector) Logger ¶ added in v0.9.3
func (rc *RabbitConnector) Logger() Logger
func (*RabbitConnector) SetLogger ¶ added in v0.9.1
func (rc *RabbitConnector) SetLogger(logger Logger)