gosqs

package
v0.0.0-...-26e3963 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ErrAWSInvalidParameter = "InvalidParameterValue"

ErrAWSInvalidParameter is returned when ReceiptHandles/VisiblityTimeout are expired (AWS SDK Error).

View Source
const ErrAWSMissingParameter = "MissingParameter"

ErrMissingParameter is returned when an empty ReceiptHandle value is passed to DeleteMessage.

View Source
const ErrAWSNonExistentQueue = "AWS.SimpleQueueService.NonExistentQueue"
View Source
const ErrInvalidQueueURL = "INVALID_QUEUE_URL"

ErrInvalidQueueURL is returned when a batch delete request is passed with an empty QueueURL field.

View Source
const ErrInvalidRequest = "IDS_NOT_EQUAL_HANDLES"

ErrInvalidRequest is returned when the number of message IDs != the number of receipt handles in a batch delete request.

View Source
const ErrTooManyRequests = "TOO_MANY_REQUESTS"

ErrTooManyRequests is returned when a batch delete request is made with > 10 receipt handles for deletion.

Variables

View Source
var QueueDefault = QueueOptions{
	DelaySeconds:                  "0",
	MaximumMessageSize:            "262144",
	MessageRetentionPeriod:        "345600",
	Policy:                        "",
	ReceiveMessageWaitTimeSeconds: "0",
	RedrivePolicy:                 "",
	VisibilityTimeout:             "30",
	KmsMasterKeyId:                "",
	KmsDataKeyReusePeriodSeconds:  "300",
	FifoQueue:                     "false",
	ContentBasedDeduplication:     "false",

	DeduplicationScope:  "queue",
	FifoThroughputLimit: "perQueue",
}

QueueDefault contains the default attribute values for new SQS Queue objects

View Source
var RecMsgDefault = RecMsgOptions{
	AttributeNames:          []*string{aws.String("All")},
	MaxNumberOfMessages:     int64(1),
	MessageAttributeNames:   []*string{aws.String("All")},
	QueueURL:                "",
	ReceiveRequestAttemptId: "",
	VisibilityTimeout:       int64(30),
	WaitTimeSeconds:         int64(0),
}

RecMsgDefault contains the default values for the sqs.ReceiveMessageInput object.

View Source
var SendMsgDefault = SendMsgOptions{
	DelaySeconds:            int64(0),
	MessageAttributes:       nil,
	MessageBody:             "",
	MessageDeduplicationId:  "",
	MessageGroupId:          "",
	MessageSystemAttributes: nil,
	QueueURL:                "",
}

SendMsgDefault contains the default options for the sqs.SendMessageInput object.

Functions

func CreateMsgAttributes

func CreateMsgAttributes(attributes []MsgAV) map[string]*sqs.MessageAttributeValue

CreateMsgAttributes creates a MessageAttributeValue map from a list of MsgAV objects. Limited to StringValue types; BinaryValue not supported.

func CreateMsgSystemAttributes

func CreateMsgSystemAttributes(attributes []MsgAV) map[string]*sqs.MessageSystemAttributeValue

CreateMsgSystemAttributes creates a MessageSystemAttributeValue map from a list of MsgAV objects Limited to StringValue types; BinaryValue not supported

func CreateQueue

func CreateQueue(svc interface{}, name string, options QueueOptions, tags map[string]*string) (string, error)

CreateQueue creates a new SQS queue per the given name, options, & tags arguments and returns the url of the queue and/or error

func DeleteMessage

func DeleteMessage(svc interface{}, url, handle string) error

DeleteMessage deletes a message from the specified queue (by url) with the given handle.

func DeleteQueue

func DeleteQueue(svc interface{}, url string) error

DeleteQueue deletes the queue at the given URL

func GenerateDedupeID

func GenerateDedupeID(msgBody string) string

GenerateDedupeID generates a MD5 hash from a timestamp of the current time + the given queue url.

func GetQueueURL

func GetQueueURL(svc interface{}, name string) (string, error)

GetQueueURL retrives the URL for the given queue name

func InitSesh

func InitSesh() interface{}

InitSesh initializes a new session with default config/credentials. Returns the *sqs.SQS object as interface{} type. The *sqs.SQS type is asserted when passed to the methods in the gosqs package.

func PurgeQueue

func PurgeQueue(svc interface{}, url string) error

PurgeQueue purges the specified queue.

Types

type BatchDeleteErrEntry

type BatchDeleteErrEntry struct {
	ErrorCode     string `json:"error_code"`
	MessageID     string `json:"message_id"`
	ReceiptHandle string `json:"receipt_handle"` // not in sqs.BatchResultErrorEntry type - added for utility
	ErrorMessage  string `json:"error_message"`
	SenderFault   bool   `json:"sender_fault"`
}

BatchDeleteErrEntry wraps the sqs.BatchResultErrorEntry type.

type BatchDeleteResultEntry

type BatchDeleteResultEntry struct {
	MessageID string `json:"message_id"`
}

BatchDeleteResultEntry wraps the sqs.DeleteMessageBatchResultEntry type.

type BatchUpdateVisibilityTimeoutEntry

type BatchUpdateVisibilityTimeoutEntry struct {
	MessageID string `json:"message_id"`
}

BatchUpdateVisibilityTimeoutEntry wraps the output *sqs.ChangeMessageVisibilityBatchResult object.

type BatchUpdateVisibilityTimeoutErrEntry

type BatchUpdateVisibilityTimeoutErrEntry struct {
	ErrorCode    string `json:"code"`
	MessageId    string `json:"id"`
	ErrorMessage string `json:"message"`
	SenderFault  bool   `json:"sender_fault"`
}

BatchUpdateVisibilityTimeoutErrEntry wraps the output *sqs.BatchResultErrorEntry object returned from BatchChangeMessageVisiblity timeout operations.

type BatchUpdateVisibilityTimeoutRequest

type BatchUpdateVisibilityTimeoutRequest struct {
	QueueURL       string   `json:"queue_url"`
	MessageIDs     []string `json:"message_ids"`
	ReceiptHandles []string `json:"receipt_handles"`
	TimeoutSeconds int      `json:"timeout_seconds"`
}

BatchUpdateVisibilityTimeoutRequest is used as input to the BatchUpdateVisibilityTimeout function.

type BatchUpdateVisibilityTimeoutResponse

type BatchUpdateVisibilityTimeoutResponse struct {
	Failed     []BatchUpdateVisibilityTimeoutErrEntry `json:"failed"`
	Successful []BatchUpdateVisibilityTimeoutEntry    `json:"successful"`
}

BatchUpdateVisibilityTimeoutRequest wraps the output of the sqs.ChangeMessageVisibilityTImeout function (*sqs.ChangeMessageVisibilityOutput).

func ChangeMessageVisibilityBatch

func ChangeMessageVisibilityBatch(svc interface{}, req BatchUpdateVisibilityTimeoutRequest) (BatchUpdateVisibilityTimeoutResponse, error)

ChangeMessageVisibilityBatch updates the visibility timeout for a batch of messages represented by the given MessageIds and ReceiptHandles. Assumes msgIDs[i] and handles[i] args are in order and correspond to the same message.

type DeleteMessageBatchRequest

type DeleteMessageBatchRequest struct {
	QueueURL       string   `json:"queue_url"`
	MessageIDs     []string `json:"message_ids"`
	ReceiptHandles []string `json:"receipt_handles"`
}

DeleteMessageBatchRequest is used to create a new BatchDelete request. len(MessageIDs) must equal len(ReceiptHandles). DeleteMessageBatch assumes the order of MessageIDs corresponds to the order ReceiptHandles.

type DeleteMessageBatchResponse

type DeleteMessageBatchResponse struct {
	Failed     []BatchDeleteErrEntry    `json:"failed"`
	Successful []BatchDeleteResultEntry `json:"successful"`
}

DeleteMessageBatchResponse wraps the sqs.DeleteMessageBatchOutput type.

func DeleteMessageBatch

func DeleteMessageBatch(svc interface{}, req DeleteMessageBatchRequest) (DeleteMessageBatchResponse, error)

DeleteMessageBatch deletes a batch of messages

type Message

type Message struct {
	Attributes              map[string]string `json:"attributes"`
	Body                    string            `json:"body"`
	MD5OfBody               string            `json:"md5_of_body"`
	MD5OfMessagefAttributes string            `json:"md5_of_message_attributes"`
	MessageAttributes       map[string]MsgAV  `json:"message_attributes"`
	MessageId               string            `json:"message_id"`
	ReceiptHandle           string            `json:"receipt_handle"`
}

Message wraps the sqs.Message type.

func ReceiveMessage

func ReceiveMessage(svc interface{}, options RecMsgOptions) ([]Message, error)

ReceiveMessage receives a message from a queue per the options argument

type MsgAV

type MsgAV struct {
	Key      string
	DataType string
	Value    string
}

MsgAV represents a single sqs.MessageAttributeValue or sqs.MessageSystemAttributeValue object. Limited to StringValue types; BinaryValue not supported.

func CreateMsgAttribute

func CreateMsgAttribute(key, dataType, value string) MsgAV

CreateMsgAttribute constructs a MsgAV object from the given parameters

type QueueOptions

type QueueOptions struct {
	DelaySeconds                  string
	MaximumMessageSize            string
	MessageRetentionPeriod        string
	Policy                        string // IAM Policy
	ReceiveMessageWaitTimeSeconds string
	RedrivePolicy                 string
	VisibilityTimeout             string
	KmsMasterKeyId                string
	KmsDataKeyReusePeriodSeconds  string
	FifoQueue                     string
	ContentBasedDeduplication     string
	DeduplicationScope            string
	FifoThroughputLimit           string
}

QueueOptions contains struct fields for setting custom options when creating a new SQS queue

type QueueTags

type QueueTags map[string]*string

QueueTags is a map object that enables tags when creating a new queue with CreateQueue()

type RecMsgOptions

type RecMsgOptions struct {
	AttributeNames          []*string
	MaxNumberOfMessages     int64
	MessageAttributeNames   []*string
	QueueURL                string
	ReceiveRequestAttemptId string
	VisibilityTimeout       int64
	WaitTimeSeconds         int64
}

RecMsgOptions is used to pass receive message options to the sqs.ReceiveMessageInput object.

type SendMsgOptions

type SendMsgOptions struct {
	DelaySeconds            int64
	MessageAttributes       map[string]*sqs.MessageAttributeValue
	MessageBody             string
	MessageDeduplicationId  string
	MessageGroupId          string
	MessageSystemAttributes map[string]*sqs.MessageSystemAttributeValue
	QueueURL                string
}

SendMsgOptions is used to pass send message options to the sqs.SendMessageInput object.

type SendMsgResponse

type SendMsgResponse struct {
	MD5OfMessageAttributes       string `json:"md5_of_message_attributes"`
	MD5OfMessageBody             string `json:"md5_of_message_body"`
	MD5OfMessageSystemAttributes string `json:"md5_of_message_system_attributes"`
	MessageId                    string `json:"message_id"`
	SequenceNumber               string `json:"sequence_number"`
}

SendMessageResponse wraps the sqs.SendMessageOutput object

func SendMessage

func SendMessage(svc interface{}, options SendMsgOptions) (SendMsgResponse, error)

SendMessage sends a new message to a queue per the options argument. Unique MD5 checksums are generated for the MessageDeduplicationID and MessageGroupID fields if not set for messages sent to FIFO Queues.

Jump to

Keyboard shortcuts

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