sqsclient

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxNumberOfMessages = 10
	DefaultVisibilityTimeout   = 30
	DefaultWaitTimeSeconds     = 20
	DefaultRegion              = "us-east-1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger added in v1.7.0

type Logger interface {
	Log(message string, v ...interface{})
}

type SQSClient

type SQSClient struct {
	Client        SQSService
	ClientOptions *SQSClientOptions
	Logger        Logger
}

func New

func New(sqsService SQSService, options SQSClientOptions) *SQSClient

func (*SQSClient) GetQueueUrl

func (s *SQSClient) GetQueueUrl() *string

GetQueueUrl returns the URL of the queue based on the queue name

func (*SQSClient) GetQueues

func (s *SQSClient) GetQueues(prefix string) []*string

GetQueues returns a list of queues based on the prefix

func (*SQSClient) Poll

func (s *SQSClient) Poll()

Poll starts polling messages from the queue

func (*SQSClient) ProcessMessage

func (s *SQSClient) ProcessMessage(sqsMessage *sqs.Message, queueUrl string)

ProcessMessage deletes or changes the visibility of the message based on the Handle function return.

func (*SQSClient) ReceiveMessages

func (s *SQSClient) ReceiveMessages(queueUrl string, ch chan *sqs.Message) error

ReceiveMessages polls messages from the queue

func (*SQSClient) SetLogger added in v1.7.0

func (s *SQSClient) SetLogger(logger Logger)

func (*SQSClient) Start

func (s *SQSClient) Start()

type SQSClientInterface

type SQSClientInterface interface {
	GetQueueUrl() *string
	ReceiveMessages(queueUrl string, ch chan *sqs.Message) error
	ProcessMessage(message *sqs.Message, queueUrl string)
	Poll()
	GetQueues(prefix string) []*string
	Start()
}

type SQSClientOptions

type SQSClientOptions struct {
	QueueName string
	// Handle is the function that will be called when a message is received.
	// Return true if you want to delete the message from the queue, otherwise, return false
	Handle   func(message *message.Message) bool
	Region   string
	Endpoint string
	// PrefixBased is a flag that indicates if the queue name is a prefix
	PrefixBased         bool
	MaxNumberOfMessages int64
	VisibilityTimeout   int64
	WaitTimeSeconds     int64
}

type SQSService

type SQSService interface {
	GetQueueUrl(input *sqs.GetQueueUrlInput) (*sqs.GetQueueUrlOutput, error)
	ReceiveMessage(input *sqs.ReceiveMessageInput) (*sqs.ReceiveMessageOutput, error)
	ChangeMessageVisibility(input *sqs.ChangeMessageVisibilityInput) (*sqs.ChangeMessageVisibilityOutput, error)
	DeleteMessage(input *sqs.DeleteMessageInput) (*sqs.DeleteMessageOutput, error)
	ListQueues(input *sqs.ListQueuesInput) (*sqs.ListQueuesOutput, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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