Documentation
¶
Index ¶
- func New(opts ...Option) func(gas.ConfigProvider, gas.Logger) *Service
- type Config
- type Option
- type Service
- func (s *Service) Ack(ctx context.Context, queueURL string, job gas.Job) error
- func (s *Service) CheckReady(_ context.Context) error
- func (s *Service) Client() *awssqs.Client
- func (s *Service) Close() error
- func (s *Service) Dequeue(ctx context.Context, queueURL string, maxMessages int, wait time.Duration) ([]gas.Job, error)
- func (s *Service) Enqueue(ctx context.Context, queueURL string, payload []byte, ...) error
- func (s *Service) Init() error
- func (s *Service) Nack(ctx context.Context, queueURL string, job gas.Job) error
- func (s *Service) Name() string
- type Settings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
env.WithGasEnv
Queue Settings
}
Config holds SQS queue settings.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a Config with sensible defaults.
type Option ¶
type Option func(*Service)
Option configures a Service.
func WithClient ¶
func WithClient(client sqsClient) Option
WithClient injects a pre-configured SQS client. Useful for testing or when the caller manages AWS credentials externally.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is an SQS-backed queue implementing gas.Service and gas.JobQueueProvider.
func (*Service) CheckReady ¶
CheckReady reports whether the service is ready to accept traffic. Returns an error before Init has run or after Close has been called.
func (*Service) Client ¶
Client returns the underlying *sqs.Client for advanced operations beyond the JobQueueProvider interface (e.g. CreateQueue, PurgeQueue, GetQueueAttributes). Returns nil if a custom sqsClient was injected via WithClient that is not an *sqs.Client.
func (*Service) Dequeue ¶
func (s *Service) Dequeue(ctx context.Context, queueURL string, maxMessages int, wait time.Duration) ([]gas.Job, error)
Dequeue receives messages from the specified SQS queue.
func (*Service) Enqueue ¶
func (s *Service) Enqueue(ctx context.Context, queueURL string, payload []byte, opts ...gas.EnqueueOption) error
Enqueue sends a message to the specified SQS queue.
type Settings ¶
type Settings struct {
// Region is the AWS region for the SQS service.
Region string
// Endpoint is an optional custom endpoint URL (e.g. for LocalStack).
// Empty means use the default AWS endpoint.
Endpoint string
// AccessKeyID is the AWS access key ID for static credentials.
// If empty, the default AWS credential chain is used.
AccessKeyID string
// SecretAccessKey is the AWS secret access key for static credentials.
// If empty, the default AWS credential chain is used.
SecretAccessKey string
// VisibilityTimeout is how long a dequeued message stays invisible
// to other consumers. SQS max is 12 hours.
VisibilityTimeout time.Duration
// WaitTimeSeconds is the long-poll duration for ReceiveMessage calls.
// Must be 0-20 (SQS hard limit).
WaitTimeSeconds int
}
Settings represents the configuration for the SQS queue service.