Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultTickerInterval is the default interval for the ticker in the consumer DefaultTickerInterval = 1 * time.Second // DefaultConsumerMessagesChannelBufferSize is the default buffer size for the consume messages channel DefaultConsumerMessagesChannelBufferSize = 100 )
Functions ¶
This section is empty.
Types ¶
type Consumer ¶
type Consumer interface {
ConsumeMessages(ctx context.Context) (
<-chan gojwtrabbitmq.TokensMessage,
error,
)
}
Consumer is the interface for the JWT RabbitMQ consumer
type DefaultConsumer ¶
type DefaultConsumer struct {
// contains filtered or unexported fields
}
DefaultConsumer is the default implementation of the Consumer interface
func NewDefaultConsumer ¶
func NewDefaultConsumer( conn *amqp091.Connection, queueName string, period time.Duration, consumerMessagesChannelBufferSize int, logger *slog.Logger, ) (*DefaultConsumer, error)
NewDefaultConsumer creates a new DefaultConsumer
Parameters:
- conn: the RabbitMQ connection
- queueName: the name of the queue
- period: the polling period
- consumerMessagesChannelBufferSize: the size of the messages buffer channel
- logger: the logger
Returns:
- *DefaultConsumer: the DefaultConsumer instance
- error: an error if the connection is nil
func (*DefaultConsumer) Close ¶
func (d *DefaultConsumer) Close() error
Close closes the RabbitMQ channel and connection
Returns:
- error: an error if the channel could not be closed
func (*DefaultConsumer) ConsumeMessages ¶
func (d *DefaultConsumer) ConsumeMessages(ctx context.Context) ( <-chan gojwtrabbitmq.TokensMessage, error, )
ConsumeMessages consumes messages from the RabbitMQ queue
Parameters:
- ctx: the context
Returns:
- <-chan gojwtrabbitmq.TokensMessage: a channel to receive the messages
- error: an error if the consumer is nil or the channel is not open
func (*DefaultConsumer) Open ¶
func (d *DefaultConsumer) Open() error
Open opens a RabbitMQ channel
Returns:
- error: an error if the channel could not be opened
Click to show internal directories.
Click to hide internal directories.