driver

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package driver defines the interface for message queue service implementations.

Index

Constants

View Source
const MaxBatchSize = 10

MaxBatchSize is the maximum number of entries allowed in a batch operation.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchDeleteEntry added in v1.2.0

type BatchDeleteEntry struct {
	ID            string
	ReceiptHandle string
}

BatchDeleteEntry represents a message to delete in batch.

type BatchDeleteResult added in v1.2.0

type BatchDeleteResult struct {
	Successful []string // entry IDs
	Failed     []BatchSendFailEntry
}

BatchDeleteResult is the result of a batch delete.

type BatchSendEntry added in v1.2.0

type BatchSendEntry struct {
	ID              string
	Body            string
	DelaySeconds    int
	GroupID         string
	DeduplicationID string
	Attributes      map[string]string
}

BatchSendEntry represents a single message in a batch send.

type BatchSendFailEntry added in v1.2.0

type BatchSendFailEntry struct {
	ID      string
	Code    string
	Message string
}

BatchSendFailEntry is a failed batch entry.

type BatchSendResult added in v1.2.0

type BatchSendResult struct {
	Successful []BatchSendResultEntry
	Failed     []BatchSendFailEntry
}

BatchSendResult is the result of a batch send.

type BatchSendResultEntry added in v1.2.0

type BatchSendResultEntry struct {
	ID        string
	MessageID string
}

BatchSendResultEntry is a successful batch entry.

type DeadLetterConfig

type DeadLetterConfig struct {
	TargetQueueURL  string
	MaxReceiveCount int // move to DLQ after this many receives
}

DeadLetterConfig configures a dead-letter queue for failed messages.

type Message

type Message struct {
	MessageID     string
	ReceiptHandle string
	Body          string
	Attributes    map[string]string
	GroupID       string
}

Message is a received message.

type MessageQueue

type MessageQueue interface {
	CreateQueue(ctx context.Context, config QueueConfig) (*QueueInfo, error)
	DeleteQueue(ctx context.Context, url string) error
	GetQueueInfo(ctx context.Context, url string) (*QueueInfo, error)
	ListQueues(ctx context.Context, prefix string) ([]QueueInfo, error)

	SendMessage(ctx context.Context, input SendMessageInput) (*SendMessageOutput, error)
	ReceiveMessages(ctx context.Context, input ReceiveMessageInput) ([]Message, error)
	DeleteMessage(ctx context.Context, queueURL, receiptHandle string) error
	ChangeVisibility(ctx context.Context, queueURL, receiptHandle string, timeout int) error

	// Batch operations
	SendMessageBatch(ctx context.Context, queue string, entries []BatchSendEntry) (*BatchSendResult, error)
	DeleteMessageBatch(ctx context.Context, queue string, entries []BatchDeleteEntry) (*BatchDeleteResult, error)

	// Enhanced receive with options
	ReceiveMessagesWithOptions(ctx context.Context, queue string, opts ReceiveOptions) ([]Message, error)

	// Queue attributes
	GetQueueAttributes(ctx context.Context, queue string) (*QueueAttributes, error)
	SetQueueAttributes(ctx context.Context, queue string, attrs map[string]int) error

	// Purge
	PurgeQueue(ctx context.Context, queue string) error
}

MessageQueue is the interface that message queue provider implementations must satisfy.

type QueueAttributes added in v1.2.0

type QueueAttributes struct {
	DelaySeconds               int
	MaximumMessageSize         int
	MessageRetentionPeriod     int // seconds
	VisibilityTimeout          int // seconds
	ApproximateMessageCount    int
	ApproximateNotVisibleCount int
	CreatedAt                  time.Time
	LastModifiedAt             time.Time
	FifoQueue                  bool
	ContentBasedDeduplication  bool
	RedrivePolicy              string // JSON string pointing to DLQ
}

QueueAttributes describes queue attributes.

type QueueConfig

type QueueConfig struct {
	Name              string
	FIFO              bool
	DelaySeconds      int
	VisibilityTimeout int // seconds
	MaxMessageSize    int
	MessageRetention  int // seconds
	Tags              map[string]string
	DeadLetterQueue   *DeadLetterConfig
}

QueueConfig describes a message queue to create.

type QueueInfo

type QueueInfo struct {
	URL                string
	ARN                string
	Name               string
	FIFO               bool
	ApproxMessageCount int
	Tags               map[string]string
}

QueueInfo describes a message queue.

type ReceiveMessageInput

type ReceiveMessageInput struct {
	QueueURL          string
	MaxMessages       int
	WaitTimeSeconds   int
	VisibilityTimeout int
}

ReceiveMessageInput configures a message receive operation.

type ReceiveOptions added in v1.2.0

type ReceiveOptions struct {
	MaxMessages       int
	WaitTimeSeconds   int // long polling: 0 = short poll, >0 = check once
	VisibilityTimeout int // override queue default
}

ReceiveOptions configures a receive operation.

type SendMessageInput

type SendMessageInput struct {
	QueueURL        string
	Body            string
	DelaySeconds    int
	GroupID         string // FIFO only
	DeduplicationID string // FIFO only
	Attributes      map[string]string
}

SendMessageInput configures a message send operation.

type SendMessageOutput

type SendMessageOutput struct {
	MessageID string
}

SendMessageOutput is the result of sending a message.

Jump to

Keyboard shortcuts

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