Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sqs prefetch to v0.2.2 #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions providers/sqs/sqs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type SQSClient struct {
sqs sqs.SQS
url string
visibilityTimeoutInSeconds int64
maxNumberOfMessages int64
unwrapSnsMessage bool
logger *zerolog.Logger
}
Expand All @@ -33,6 +34,7 @@ type SnsMessage struct {

func createSQSClient(cfg *viper.Viper, logger *zerolog.Logger) *SQSClient {
cfg.SetDefault("visibilityTimeoutInSeconds", 600)
cfg.SetDefault("maxNumberOfMessages", 10)
cfg.SetDefault("unwrapSnsMessage", false)

awsConfig := aws.NewConfig().WithRegion(cfg.GetString("region"))
Expand All @@ -45,6 +47,7 @@ func createSQSClient(cfg *viper.Viper, logger *zerolog.Logger) *SQSClient {
*svc,
cfg.GetString("url"),
cfg.GetInt64("visibilityTimeoutInSeconds"),
cfg.GetInt64("maxNumberOfMessages"),
cfg.GetBool("unwrapSnsMessage"),
logger,
}
Expand Down Expand Up @@ -92,10 +95,9 @@ Main:
break Main
default:
}
var maxMessages int64 = 10
messages, err := c.sqs.ReceiveMessage(&sqs.ReceiveMessageInput{
QueueUrl: &c.url,
MaxNumberOfMessages: &maxMessages,
MaxNumberOfMessages: &c.maxNumberOfMessages,
VisibilityTimeout: &c.visibilityTimeoutInSeconds,
})

Expand Down