sqs

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2022 License: MIT Imports: 8 Imported by: 4

README

Go Reference GitHub go.mod Go version GitHub release (latest by date) Go Report Card Actions Status

AWS SQS

This package provides a wrapper for AWS SQS used in my projects.

Documentation

Overview

Package sqs provides publisher and receiver to interact with AWS SQS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides access to AWS SQS to send and receive messages.

func (*Client) Ack added in v1.1.0

func (client *Client) Ack(queueName string, receiptHandle *string) error

Confirm that the message was received. This will delete this message from given queue.

func (*Client) Receive

func (client *Client) Receive(queueName string) ([]RawMessage, error)

Receive will try to read message from given queue.

func (*Client) Send

func (client *Client) Send(message interface{}, queueName string) (*string, error)

Send will marshal passed message and try to deliver it to AWS SQS. If successful it returns the message id.

func (*Client) SendAttributedMessage added in v1.0.3

func (client *Client) SendAttributedMessage(message interface{}, queueName string, attributes map[string]string) (*string, error)

SendAttributedMessage will marshal given message to JSON if it's not already a byte array, try to send it to AWS SQS using passed message attributes and will return the message id in case of successful delivering.

type Consumer

type Consumer interface {

	// Receive will read messages from given queue in AWS SQS.
	Receive(string) ([]RawMessage, error)

	// Confirm that the message was received. This will delete this message from given queue.
	Ack(string, *string) error
}

Consumer provides read access to message queues in AWS SQS.

func NewConsumer

func NewConsumer(conf config.Config) Consumer

NewConsumer returns a client to read messages from an AWS SQS queue.

type Publisher

type Publisher interface {

	// Send will marshal given message to JSON if it's not already a byte array,
	// try to send it to AWS SQS and will return the message id in case of successful delivering.
	Send(interface{}, string) (*string, error)

	// SendAttributedMessage will marshal given message to JSON if it's not already a byte array,
	// try to send it to AWS SQS using passed message attributes and will return the message id
	// in case of successful delivering.
	SendAttributedMessage(interface{}, string, map[string]string) (*string, error)
}

Publisher provides message sending functionality.

func NewPublisher

func NewPublisher(conf config.Config) Publisher

NewPublisher returns a new publisher used to send messages to AWS SQS.

type RawMessage

type RawMessage struct {

	// MessageId is the id of a message in AWS SQS.
	MessageId *string

	// ReceiptHandle is the receipt handle in AWS SQS.
	ReceiptHandle *string

	// Body contains the message body read from AWS SQS.
	Body *string
}

RawMessage is used to return messages read from a queue in AWS SQS.

Jump to

Keyboard shortcuts

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