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
8ce6763b
Commit
8ce6763b
authored
3 years ago
by
Francé Wilke
Browse files
Options
Downloads
Patches
Plain Diff
Pass sqs message type through
parent
4fc59fc3
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sqs/sqs.go
+8
-3
8 additions, 3 deletions
sqs/sqs.go
with
8 additions
and
3 deletions
sqs/sqs.go
+
8
−
3
View file @
8ce6763b
...
@@ -49,7 +49,7 @@ func NewSQSMessenger(awsRegion, queueUrl string) (*Messenger, error) {
...
@@ -49,7 +49,7 @@ func NewSQSMessenger(awsRegion, queueUrl string) (*Messenger, error) {
// SendSQSMessage sends a message to the queue associated with the messenger
// SendSQSMessage sends a message to the queue associated with the messenger
// headers - string message attributes of the SQS message (see AWS SQS documentation)
// headers - string message attributes of the SQS message (see AWS SQS documentation)
// body - body of the SQS message (see AWS SQS documentation)
// body - body of the SQS message (see AWS SQS documentation)
func
(
m
*
Messenger
)
SendSQSMessage
(
headers
map
[
string
]
string
,
body
string
,
currentRequestID
*
string
,
headerKey
string
)
(
string
,
error
)
{
func
(
m
*
Messenger
)
SendSQSMessage
(
headers
map
[
string
]
string
,
body
string
,
currentRequestID
*
string
,
sqsType
string
,
headerKey
string
)
(
string
,
error
)
{
msgAttrs
:=
make
(
map
[
string
]
*
sqs
.
MessageAttributeValue
)
msgAttrs
:=
make
(
map
[
string
]
*
sqs
.
MessageAttributeValue
)
for
key
,
val
:=
range
headers
{
for
key
,
val
:=
range
headers
{
...
@@ -67,6 +67,11 @@ func (m *Messenger) SendSQSMessage(headers map[string]string, body string, curre
...
@@ -67,6 +67,11 @@ func (m *Messenger) SendSQSMessage(headers map[string]string, body string, curre
}
}
}
}
msgAttrs
[
"type"
]
=
&
sqs
.
MessageAttributeValue
{
DataType
:
aws
.
String
(
"String"
),
StringValue
:
aws
.
String
(
sqsType
),
}
res
,
err
:=
m
.
service
.
SendMessage
(
&
sqs
.
SendMessageInput
{
res
,
err
:=
m
.
service
.
SendMessage
(
&
sqs
.
SendMessageInput
{
MessageAttributes
:
msgAttrs
,
MessageAttributes
:
msgAttrs
,
MessageBody
:
aws
.
String
(
body
),
MessageBody
:
aws
.
String
(
body
),
...
@@ -80,7 +85,7 @@ func (m *Messenger) SendSQSMessage(headers map[string]string, body string, curre
...
@@ -80,7 +85,7 @@ func (m *Messenger) SendSQSMessage(headers map[string]string, body string, curre
return
*
res
.
MessageId
,
err
return
*
res
.
MessageId
,
err
}
}
func
SendSQSMessage
(
msgr
*
Messenger
,
region
string
,
envQueueURLName
string
,
objectToSend
interface
{},
currentRequestID
*
string
,
headerKey
string
)
error
{
func
SendSQSMessage
(
msgr
*
Messenger
,
region
string
,
envQueueURLName
string
,
objectToSend
interface
{},
currentRequestID
*
string
,
sqsType
string
,
headerKey
string
)
error
{
if
msgr
==
nil
{
if
msgr
==
nil
{
var
err
error
var
err
error
msgr
,
err
=
NewSQSMessenger
(
region
,
os
.
Getenv
(
envQueueURLName
))
msgr
,
err
=
NewSQSMessenger
(
region
,
os
.
Getenv
(
envQueueURLName
))
...
@@ -96,7 +101,7 @@ func SendSQSMessage(msgr *Messenger, region string, envQueueURLName string, obje
...
@@ -96,7 +101,7 @@ func SendSQSMessage(msgr *Messenger, region string, envQueueURLName string, obje
}
}
headers
:=
map
[
string
]
string
{
"Name"
:
"dummy"
}
headers
:=
map
[
string
]
string
{
"Name"
:
"dummy"
}
msgID
,
err
:=
msgr
.
SendSQSMessage
(
headers
,
string
(
jsonBytes
),
currentRequestID
,
headerKey
)
msgID
,
err
:=
msgr
.
SendSQSMessage
(
headers
,
string
(
jsonBytes
),
currentRequestID
,
sqsType
,
headerKey
)
if
err
!=
nil
{
if
err
!=
nil
{
logs
.
ErrorWithMsg
(
"Failed to send sqs event"
,
err
)
logs
.
ErrorWithMsg
(
"Failed to send sqs event"
,
err
)
return
err
return
err
...
...
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