Skip to content
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
12 changes: 11 additions & 1 deletion internal/mqs/queue_awssqs.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ import (
"github.com/aws/aws-sdk-go/aws"
"gocloud.dev/pubsub"
"gocloud.dev/pubsub/awssnssqs"
"gocloud.dev/pubsub/batcher"
)

// sqsMaxBatchBytes is the maximum total payload size for an SQS SendMessageBatch
// request. SQS rejects batches exceeding 256 KB per message and 1 MB per batch.
// Setting this on the gocloud batcher prevents oversized batches from being sent.
const sqsMaxBatchBytes = 1_048_576 // 1 MB

type AWSSQSConfig struct {
Endpoint string // optional - dev-focused
Region string
Expand Down Expand Up @@ -56,7 +62,11 @@ func (q *AWSQueue) Init(ctx context.Context) (func(), error) {
if err != nil {
return nil, err
}
q.topic = awssnssqs.OpenSQSTopicV2(ctx, q.sqsClient, q.sqsQueueURL, nil)
q.topic = awssnssqs.OpenSQSTopicV2(ctx, q.sqsClient, q.sqsQueueURL, &awssnssqs.TopicOptions{
BatcherOptions: batcher.Options{
MaxBatchByteSize: sqsMaxBatchBytes,
},
})
return func() {
q.topic.Shutdown(ctx)
}, nil
Expand Down
Loading