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