Skip to content
Snippets Groups Projects
Commit ea28c3d4 authored by Johan de Klerk's avatar Johan de Klerk
Browse files

Merge branch 'main' of gitlab.com:uafrica/go-utils

parents eb776075 19ae7e45
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,6 @@ import (
"fmt"
"github.com/google/uuid"
"gitlab.com/uafrica/go-utils/s3"
"gitlab.com/uafrica/go-utils/string_utils"
"io/ioutil"
"time"
......@@ -29,6 +28,7 @@ type Messenger struct {
S3Session *s3.SessionWithHelpers
S3BucketName string
MessageGroupID *string
DelaySeconds *int64
RequestIDHeaderKey string
}
......@@ -79,22 +79,21 @@ func (m *Messenger) SendSQSMessage(headers map[string]string, body string, curre
StringValue: aws.String(sqsType),
}
// SQS has max of 15 minutes delay
// https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html
if m.DelaySeconds != nil && aws.Int64Value(m.DelaySeconds) > 900 {
m.DelaySeconds = aws.Int64(900)
}
var res *sqs.SendMessageOutput
var err error
if string_utils.UnwrapString(m.MessageGroupID) == "" {
res, err = sqsClient.SendMessage(&sqs.SendMessageInput{
MessageAttributes: msgAttrs,
MessageBody: aws.String(body),
QueueUrl: &m.QueueURL,
})
} else {
res, err = sqsClient.SendMessage(&sqs.SendMessageInput{
MessageAttributes: msgAttrs,
MessageBody: aws.String(body),
QueueUrl: &m.QueueURL,
MessageGroupId: m.MessageGroupID,
DelaySeconds: m.DelaySeconds,
})
}
if err != nil {
return "", err
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment