Documentation
¶
Index ¶
- type HandlerFunc
- type Message
- type Option
- func WithBatchSize(n int) Option
- func WithDeleteBatchSize(n int) Option
- func WithDeleteBatchWindow(d time.Duration) Option
- func WithLogger(l *slog.Logger) Option
- func WithQueueURL(url string) Option
- func WithSQSClient(c sqsClient) Option
- func WithVisibilityTimeoutSeconds(n int32) Option
- func WithWaitTimeSeconds(n int32) Option
- func WithWorkerCount(n int) Option
- type Options
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HandlerFunc ¶
HandlerFunc is invoked for each received batch.
The handler should handle errors internally. Messages are only deleted if your handler calls `Message.Mark()` on them.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message wraps an SQS message and provides a best-effort Mark() API for background deletion.
type Option ¶
Option mutates Options (variadic functional options style).
func WithBatchSize ¶
func WithDeleteBatchSize ¶
func WithDeleteBatchWindow ¶
func WithLogger ¶
func WithQueueURL ¶
func WithSQSClient ¶
func WithSQSClient(c sqsClient) Option
func WithWaitTimeSeconds ¶
func WithWorkerCount ¶
type Options ¶
type Options struct {
// Required
QueueURL string
// Optional. If nil, New() should create a client using gommon/pkg/aws GetConfig().
Client sqsClient
// Optional. If nil, the worker should use slog.Default().
Logger *slog.Logger
// Concurrency
WorkerCount int
// Batching
// BatchSize controls how many messages are passed to your handler per job.
// Note: SQS ReceiveMessage MaxNumberOfMessages is <= 10, and the worker currently
// maps receive batch == handler batch, so BatchSize must be 1..10.
BatchSize int
// ReceiveMessage tuning
// WaitTimeSeconds controls SQS long-polling (0..20).
WaitTimeSeconds int32
// VisibilityTimeoutSeconds overrides the per-receive visibility timeout.
// If nil, the queue default visibility timeout applies.
VisibilityTimeoutSeconds *int32
// Delete batching
// DeleteBatchSize controls max entries per DeleteMessageBatch call (1..10).
DeleteBatchSize int
// DeleteBatchWindow controls periodic flushing even if the delete batch isn't full.
DeleteBatchWindow time.Duration
}
Options holds all configurable settings for Worker construction.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns a fully-populated Options struct with sane defaults. QueueURL is still required and must be set via WithQueueURL (or directly) before validation.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}