sqs

package
v0.0.0-...-745247c Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 12 Imported by: 5

Documentation

Overview

Package sqs is for messaging with AWS SQS.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoMessages = errors.New("no messages received from queue")

specific error to return when no messages are received from the queue

Functions

func Cancelled

func Cancelled(err error) bool

func IsNoMessagesError

func IsNoMessagesError(err error) bool

Types

type Raw

type Raw struct {
	Body          string
	ReceiptHandle string
	Attributes    map[string]string
}

type SQS

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

func New

func New() (SQS, error)

New returns an SQS struct which wraps an SQS client using the default AWS credentials chain. This consults (in order) environment vars, config files, EC2 and ECS roles. It is an error if the AWS_REGION environment variable is not set. Requests with recoverable errors will be retried with the default retrier.

func NewWithMaxRetries

func NewWithMaxRetries(maxRetries int) (SQS, error)

NewWithMaxRetries returns the same as New(), but with the back off set to up to maxRetries times.

func (*SQS) CheckQueue

func (s *SQS) CheckQueue(queueUrl string) error

CheckQueue checks if the given SQS queue exists and is accessible.

func (*SQS) CreateQueue

func (s *SQS) CreateQueue(queueName string, isFifoQueue bool) (string, error)

CreateQueue creates an Amazon SQS queue with the specified name. You can specify whether the queue is created as a FIFO queue. Returns the queue URL.

func (*SQS) Delete

func (s *SQS) Delete(queueURL, receiptHandle string) error

Delete deletes the message referred to by receiptHandle from the queue.

func (*SQS) DeleteQueue

func (s *SQS) DeleteQueue(queueUrl string) error

DeleteQueue deletes an Amazon SQS queue.

func (*SQS) GetQueueARN

func (s *SQS) GetQueueARN(url string) (string, error)

func (*SQS) GetQueueUrl

func (s *SQS) GetQueueUrl(name string) (string, error)

GetQueueUrl returns an AWS SQS queue URL given its name.

func (*SQS) Ready

func (s *SQS) Ready() bool

Ready returns whether the SQS client has been initialised.

func (*SQS) Receive

func (s *SQS) Receive(queueURL string, visibilityTimeout int32) (Raw, error)

Receive receives a raw message or error from the queue. After a successful receive the message will be in flight until it is either deleted or the visibility timeout expires (at which point it is available for redelivery).

Applications should be able to handle duplicate or out of order messages, and should back off on Receive error.

func (*SQS) ReceiveWithAttributes

func (s *SQS) ReceiveWithAttributes(queueURL string, visibilityTimeout int32, attrs []types.QueueAttributeName) (Raw, error)

ReceiveWithAttributes is the same as Receive except that Queue Attributes can be requested to be received with the message.

func (*SQS) ReceiveWithContext

func (s *SQS) ReceiveWithContext(ctx context.Context, queueURL string, visibilityTimeout int32) (Raw, error)

receive with context so that system stop signal can be received, to receive system stop signal, register the context with signal.NotifyContext before passing in this function, when system stop signal is received, an error with message '... context canceled' will be returned which can be used to safely stop the system

func (*SQS) ReceiveWithContextAttributes

func (s *SQS) ReceiveWithContextAttributes(ctx context.Context, queueURL string, visibilityTimeout int32, attrs []types.QueueAttributeName) (Raw, error)

ReceiveWithContextAttributes by context and Queue Attributes, so that system stop signal can be received by the context. to receive system stop signal, register the context with signal.NotifyContext before passing in this function, when system stop signal is received, an error with message '... context canceled' will be returned which can be used to safely stop the system

func (*SQS) Send

func (s *SQS) Send(queueURL string, body string) error

Send sends the message body to the SQS queue referred to by queueURL.

func (*SQS) SendBatch

func (s *SQS) SendBatch(ctx context.Context, queueURL string, bodies []string) error

Leverage the sendbatch api for uploading large numbers of messages

func (*SQS) SendFifoMessage

func (s *SQS) SendFifoMessage(queue, group, dedupe string, msg []byte) (string, error)

SendFifoMessage puts a message onto the given AWS SQS queue.

func (*SQS) SendNBatch

func (s *SQS) SendNBatch(ctx context.Context, queueURL string, bodies []string) error

func (*SQS) SendWithDelay

func (s *SQS) SendWithDelay(queueURL string, body string, delay int32) error

SendWithDelay is the same as Send but adds a delay (in seconds) before sending.

Jump to

Keyboard shortcuts

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