Skip to content
Snippets Groups Projects
Commit 1e929d44 authored by Jano Hendriks's avatar Jano Hendriks
Browse files

Revert DelaySeconds to an int64 pointer

parent 276ae716
No related branches found
No related tags found
1 merge request!48Migrate to aws sdk for go v2
......@@ -6,6 +6,7 @@ import (
"context"
"encoding/json"
"fmt"
"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/utils"
"io"
"time"
......@@ -32,7 +33,7 @@ type Messenger struct {
S3Client *s3.ClientWithHelpers
S3BucketName string
MessageGroupID *string
DelaySeconds int32
DelaySeconds *int64
RequestIDHeaderKey string
}
......@@ -79,8 +80,12 @@ func (m *Messenger) SendSQSMessage(headers map[string]string, body string, curre
// SQS has max of 15 minutes delay
// https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html
if m.DelaySeconds != 0 && m.DelaySeconds > 900 {
m.DelaySeconds = 900
var delaySeconds int32
if m.DelaySeconds != nil {
if *m.DelaySeconds > 900 {
m.DelaySeconds = utils.ValueToPointer(int64(900))
}
delaySeconds = int32(*m.DelaySeconds)
}
var res *sqs.SendMessageOutput
......@@ -90,7 +95,7 @@ func (m *Messenger) SendSQSMessage(headers map[string]string, body string, curre
MessageBody: aws.String(body),
QueueUrl: &m.QueueURL,
MessageGroupId: m.MessageGroupID,
DelaySeconds: m.DelaySeconds,
DelaySeconds: delaySeconds,
})
if err != nil {
......@@ -104,8 +109,8 @@ func SendSQSMessage(msgr Messenger, objectToSend interface{}, currentRequestID *
if isDebug {
go func() {
if msgr.DelaySeconds != 0 {
delay := msgr.DelaySeconds
if msgr.DelaySeconds != nil {
delay := *msgr.DelaySeconds
time.Sleep(time.Second * time.Duration(delay))
}
resty.New().R().
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment