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
809fb167
Commit
809fb167
authored
1 year ago
by
Daniel Naude
Browse files
Options
Downloads
Patches
Plain Diff
rename session to client
parent
cca23cda
No related branches found
No related tags found
1 merge request
!48
Migrate to aws sdk for go v2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
handler_utils/sqs.go
+2
-2
2 additions, 2 deletions
handler_utils/sqs.go
sqs/sqs.go
+4
-4
4 additions, 4 deletions
sqs/sqs.go
with
6 additions
and
6 deletions
handler_utils/sqs.go
+
2
−
2
View file @
809fb167
...
@@ -30,13 +30,13 @@ func ValidateSQSEndpoints(endpoints map[string]interface{}) (map[string]interfac
...
@@ -30,13 +30,13 @@ func ValidateSQSEndpoints(endpoints map[string]interface{}) (map[string]interfac
return
endpoints
,
nil
return
endpoints
,
nil
}
}
func
GetRecord
(
s3
Session
*
s3
.
Session
WithHelpers
,
bucket
string
,
message
events
.
SQSMessage
,
recordType
reflect
.
Type
)
(
interface
{},
error
)
{
func
GetRecord
(
s3
Client
*
s3
.
Client
WithHelpers
,
bucket
string
,
message
events
.
SQSMessage
,
recordType
reflect
.
Type
)
(
interface
{},
error
)
{
recordValuePtr
:=
reflect
.
New
(
recordType
)
recordValuePtr
:=
reflect
.
New
(
recordType
)
// Check if message body should be retrieved from S3
// Check if message body should be retrieved from S3
if
messageAttribute
,
ok
:=
message
.
MessageAttributes
[
sqs
.
SQSMessageOnS3Key
];
ok
&&
messageAttribute
.
StringValue
!=
nil
&&
*
messageAttribute
.
StringValue
==
"true"
{
if
messageAttribute
,
ok
:=
message
.
MessageAttributes
[
sqs
.
SQSMessageOnS3Key
];
ok
&&
messageAttribute
.
StringValue
!=
nil
&&
*
messageAttribute
.
StringValue
==
"true"
{
messageBytes
,
err
:=
sqs
.
RetrieveMessageFromS3
(
s3
Session
,
bucket
,
message
.
Body
)
messageBytes
,
err
:=
sqs
.
RetrieveMessageFromS3
(
s3
Client
,
bucket
,
message
.
Body
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"failed to get sqs message body from s3"
)
return
nil
,
errors
.
Wrapf
(
err
,
"failed to get sqs message body from s3"
)
}
}
...
...
This diff is collapsed.
Click to expand it.
sqs/sqs.go
+
4
−
4
View file @
809fb167
...
@@ -162,10 +162,10 @@ func SendSQSMessage(msgr Messenger, objectToSend interface{}, currentRequestID *
...
@@ -162,10 +162,10 @@ func SendSQSMessage(msgr Messenger, objectToSend interface{}, currentRequestID *
return
nil
return
nil
}
}
func
uploadMessageToS3
(
session
*
s3
.
ClientWithHelpers
,
bucket
string
,
name
string
,
messageBytes
[]
byte
)
error
{
func
uploadMessageToS3
(
client
*
s3
.
ClientWithHelpers
,
bucket
string
,
name
string
,
messageBytes
[]
byte
)
error
{
// Upload message
// Upload message
expiry
:=
24
*
7
*
time
.
Hour
// 3 days
expiry
:=
24
*
7
*
time
.
Hour
// 3 days
_
,
err
:=
session
.
UploadWithSettings
(
messageBytes
,
bucket
,
name
,
s3
.
S3UploadSettings
{
_
,
err
:=
client
.
UploadWithSettings
(
messageBytes
,
bucket
,
name
,
s3
.
S3UploadSettings
{
ExpiryDuration
:
&
expiry
,
ExpiryDuration
:
&
expiry
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -175,9 +175,9 @@ func uploadMessageToS3(session *s3.ClientWithHelpers, bucket string, name string
...
@@ -175,9 +175,9 @@ func uploadMessageToS3(session *s3.ClientWithHelpers, bucket string, name string
return
nil
return
nil
}
}
func
RetrieveMessageFromS3
(
session
*
s3
.
ClientWithHelpers
,
bucket
string
,
filename
string
)
([]
byte
,
error
)
{
func
RetrieveMessageFromS3
(
client
*
s3
.
ClientWithHelpers
,
bucket
string
,
filename
string
)
([]
byte
,
error
)
{
// get the file contents
// get the file contents
rawObject
,
err
:=
session
.
GetObject
(
bucket
,
filename
,
false
)
rawObject
,
err
:=
client
.
GetObject
(
bucket
,
filename
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
[]
byte
{},
err
return
[]
byte
{},
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