Skip to content

Commit

Permalink
pubsub: expose receiver max batch size via url parm
Browse files Browse the repository at this point in the history
Signed-off-by: pxp928 <parth.psu@gmail.com>
  • Loading branch information
pxp928 committed Mar 31, 2024
1 parent be1b4ae commit a0ed278
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pubsub/awssnssqs/awssnssqs.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ const SQSScheme = "awssqs"
// - nacklazy (for "awssqs" Subscriptions only): sets SubscriberOptions.NackLazy. The
// value must be parseable by `strconv.ParseBool`.
// - waittime: sets SubscriberOptions.WaitTime, in time.ParseDuration formats.
// - receivermaxbatch: sets the receiver max batch size as an integer.
// SQS supports receiving at most 10 messages at a time:
// https://godoc.org/github.com/aws/aws-sdk-go/service/sqs#SQS.ReceiveMessage
//
// See gocloud.dev/aws/ConfigFromURLParams for other query parameters
// that affect the default AWS session.
Expand Down Expand Up @@ -302,6 +305,14 @@ func (o *URLOpener) OpenSubscriptionURL(ctx context.Context, u *url.URL) (*pubsu
}
q.Del("waittime")
}
if receiverMaxBatchStr := q.Get("receivermaxbatch"); receiverMaxBatchStr != "" {
var err error
opts.ReceiveBatcherOptions.MaxBatchSize, err = strconv.Atoi(receiverMaxBatchStr)
if err != nil {
return nil, fmt.Errorf("invalid value %q for receivermaxbatch: %v", receiverMaxBatchStr, err)
}
q.Del("recievermaxbatch")
}
qURL := "https://" + path.Join(u.Host, u.Path)
if o.UseV2 {
cfg, err := gcaws.V2ConfigFromURLParams(ctx, q)
Expand Down

0 comments on commit a0ed278

Please sign in to comment.