sqs

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package sqs provides default implementations for using AWS SQS with the runtimes in the queue package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchDeleteProcessor

type BatchDeleteProcessor struct {
	// contains filtered or unexported fields
}

BatchDeleteProcessor will concurrently process and delete messages from AWS SQS.

func NewBatchDeleteProcessor

func NewBatchDeleteProcessor(opts ...BatchDeleteProcessorOption) *BatchDeleteProcessor

NewBatchDeleteProcessor returns a fully initially BatchDeleteProcessor.

func (*BatchDeleteProcessor) Process

func (p *BatchDeleteProcessor) Process(ctx context.Context, msgs []types.Message) error

Process implements the queue.Processor interface.

Each message is processed concurrently using the processor that was provided to the BatchDeleteProcessor when it was created. If the inner processor returns an error for a message, it will not be deleted from SQS and will be reprocessed after the VisibilityTimeout expires. If no error is returned, the message will be collected with the other messages from the slice, msgs, to be deleted together in a single BatchDelete request to SQS.

type BatchDeleteProcessorOption

type BatchDeleteProcessorOption interface {
	// contains filtered or unexported methods
}

BatchDeleteProcessorOption are options for configuring the BatchDeleteProcessor.

func Processor

Processor configures the underlying single message queue.Processor which the BatchDeleteProcessor calls when concurrently processing a batch of messages.

type CommonOption

type CommonOption interface {
	ConsumerOption
	BatchDeleteProcessorOption
}

CommonOption are options common to all AWS SQS related consumers and processors.

func Client

func Client(c *sqs.Client) CommonOption

Client configures the underlying SQS client.

func LogHandler

func LogHandler(h slog.Handler) CommonOption

LogHandler configures the underlying slog.Handler.

func QueueUrl

func QueueUrl(url string) CommonOption

QueueUrl configures the SQS queue url.

type Consumer

type Consumer struct {
	// contains filtered or unexported fields
}

Consumer consumes messages from AWS SQS.

func NewConsumer

func NewConsumer(opts ...ConsumerOption) *Consumer

NewConsumer returns a fully initialized Consumer.

func (*Consumer) Consume

func (c *Consumer) Consume(ctx context.Context) ([]types.Message, error)

Consume implements the queue.Consumer interface.

A ReceiveMessage request is sent to AWS SQS with the configured options (e.g. visibility timeout, wait time seconds, etc.). An error is only returned in the case where the SQS request fails or SQS returns zero messages. In the case of zero messages, the error, queue.ErrNoItem, is returned which allows the queue based runtimes to disregard this as a failure and retry consuming messages.

type ConsumerOption

type ConsumerOption interface {
	// contains filtered or unexported methods
}

ConsumerOption are options for configuring the Consumer.

func MaxNumOfMessages

func MaxNumOfMessages(n int32) ConsumerOption

MaxNumOfMessages defines the maximum number of messages which Amazon SQS will return in a single response.

Amazon SQS never returns more messages than this value (however, fewer messages might be returned). The minimum is 1. The maximum is 10.

func VisibilityTimeout

func VisibilityTimeout(n int32) ConsumerOption

VisibilityTimeout a period of time during which Amazon SQS prevents all consumers from receiving and processing the message.

The default visibility timeout for a message is 30 seconds. The minimum is 0 seconds. The maximum is 12 hours.

func WaitTimeSeconds

func WaitTimeSeconds(n int32) ConsumerOption

WaitTimeSeconds is the duration (in seconds) for which the call waits for a message to arrive in the queue before returning. If a message is available, the call returns sooner than WaitTimeSeconds. If no messages are available and the wait time expires, the call returns successfully with an empty list of messages. To avoid HTTP errors, ensure that the HTTP response timeout for ReceiveMessage requests is longer than the WaitTimeSeconds parameter.

Directories

Path Synopsis
Package sqsslog provides slog helpers for SQS related data fields.
Package sqsslog provides slog helpers for SQS related data fields.

Jump to

Keyboard shortcuts

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