Documentation
¶
Index ¶
Constants ¶
const ( // MaxLongPollDuration is the maximum duration for SQS long polling // https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-long-polling.html MaxLongPollDuration = 20 * time.Second // MaxBatchSize is the largest number of messages that can be processed in a batch SQS request. // It applies to ReceiveMessage (MaxNumberOfMessages) and DeleteMessageBatch (DeleteMessageBatchRequestEntry.N) // https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ReceiveMessage.html // https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_DeleteMessageBatch.html MaxBatchSize = 10 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BatchDeleteError ¶
BatchDeleteError represents an error returned from SQS in response to a DeleteMessageBatch request
func (*BatchDeleteError) Error ¶
func (err *BatchDeleteError) Error() string
type DeleteOptions ¶
DeleteOptions configures deletion of messages from SQS
type Dispatch ¶
type Dispatch struct { Options Options // contains filtered or unexported fields }
Dispatch provides methods for processing messages SQS via channels
func (*Dispatch) BatchDeletes ¶
func (d *Dispatch) BatchDeletes(deletes <-chan *sqs.Message) <-chan []*sqs.DeleteMessageBatchRequestEntry
BatchDeletes buffers messages received on the delete channel, batching according to the Delete.Interval and the MaxBatchSize
func (*Dispatch) Delete ¶
Delete processes messages received on the delete channel until the supplied context is canceled. It batching messages with BatchDeletes and calls the SQS DeleteMessageBatch API to trigger deletion. If there are failures in the DeleteMessageBatchOutput, it sends one error per failure to the errors channel.
func (*Dispatch) QueueURL ¶
QueueURL returns the SQS Queue URL specified with Options.Receive.ReceiveMessageInput
func (*Dispatch) Receive ¶
Receive runs a loop that receives messages from SQS until the supplied context is canceled. It checks for available space on the receive channel's buffer. It fetches up to that number of messages from SQS and sends them to the receive channel. If the receive buffer is full, it continues looping until capacity is detected. Because SQS bills per API request, ReceiveMessageInput.WaitTimeSeconds allows the loop to block for up to 20 seconds if no messages are available to receive which results in ~3 requests per minute instead of hundreds when your queue is idle.
func (*Dispatch) ReceiveCapacity ¶
ReceiveCapacity returns the available space in the receive channel's buffer. This is used to determine how many ReceiveMessage requests to issue and how many messages (count) are requested in each.
type Options ¶
type Options struct { Receive ReceiveOptions Delete DeleteOptions SQS sqsiface.SQSAPI }
Options represents the user-configurable options for a Dispatch
type ReceiveOptions ¶
type ReceiveOptions struct { BufferSize int RecieveMessageInput *sqs.ReceiveMessageInput }
ReceiveOptions configures receiving of messages from SQS