Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bobgroup-go-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bob Public Utils
bobgroup-go-utils
Commits
1e929d44
Commit
1e929d44
authored
1 year ago
by
Jano Hendriks
Browse files
Options
Downloads
Patches
Plain Diff
Revert DelaySeconds to an int64 pointer
parent
276ae716
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!48
Migrate to aws sdk for go v2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sqs/sqs.go
+11
-6
11 additions, 6 deletions
sqs/sqs.go
with
11 additions
and
6 deletions
sqs/sqs.go
+
11
−
6
View file @
1e929d44
...
@@ -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
int
32
DelaySeconds
*
int
64
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
.
D
elaySeconds
,
DelaySeconds
:
d
elaySeconds
,
})
})
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
()
.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment