sqs

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package sqs is the SQS adapter for object-storage events: it polls an SQS queue fed by S3 bucket notifications, parses each message into an objectstorage.Event, and dispatches it through an objectstorage.Router. Application handlers depend on objectstorage, not on this package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(cfg Config) (*sqs.Client, error)

NewClient creates an SQS client. Uses static credentials if Key/Secret are set; otherwise falls back to the default AWS credential chain (IRSA on EKS).

Types

type API

type API interface {
	ReceiveMessage(context.Context, *sqs.ReceiveMessageInput, ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error)
	DeleteMessage(context.Context, *sqs.DeleteMessageInput, ...func(*sqs.Options)) (*sqs.DeleteMessageOutput, error)
}

API is the subset of the AWS SQS client the poller depends on. *sqs.Client satisfies it; tests supply a fake so the poll/ack logic is exercised without a live queue.

type Config

type Config struct {
	QueueURL          string `mapstructure:"queue_url"`
	AWSRegion         string `mapstructure:"aws_region"`
	Key               string `mapstructure:"key"` // optional static credential; falls back to the default AWS chain (IRSA) when empty
	Secret            string `mapstructure:"secret"`
	Endpoint          string `mapstructure:"endpoint"` // optional custom endpoint (e.g. LocalStack)
	MaxMessages       int32  `mapstructure:"max_messages"`
	WaitTimeSeconds   int32  `mapstructure:"wait_time_seconds"`
	VisibilityTimeout int32  `mapstructure:"visibility_timeout"`
}

Config carries the SQS connection and polling parameters. The mapstructure tags let a service load it directly from JSON (alias it) instead of redeclaring the schema.

type EventRouter

type EventRouter interface {
	Handle(objectstorage2.Event) error
}

EventRouter dispatches a parsed object-storage event to its registered handler. The poller declares the narrow behaviour it needs rather than importing the concrete router, so the composition root owns the binding (the objectstorage.Router satisfies it).

type Poller

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

func NewPoller

func NewPoller(
	l logger.Logger,
	cfg Config,
	client API,
	router EventRouter,
) (*Poller, error)

func (*Poller) Start

func (p *Poller) Start(ctx context.Context) error

func (*Poller) Stop

func (p *Poller) Stop(ctx context.Context) error

Jump to

Keyboard shortcuts

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