google / go-cloud

The Go Cloud Development Kit (Go CDK): A library and tools for open cloud development in Go.
https://gocloud.dev/
Apache License 2.0
9.45k stars 799 forks source link

pubsub/rabbitpubsub: add support to qos prefetch count via url query string #3430

Closed peczenyj closed 1 month ago

peczenyj commented 1 month ago

Is your feature request related to a problem? Please describe.

Today we can't set the QoS prefetch count when we open a subscription to a rabbitmq queue.

Describe the solution you'd like

I check how kafka handle query strings and I add support to prefetch_count=<prefetch count value> that should be transparent when using a rabbit://queue url format like rabbit://queue?prefetch_coint=1000 to set the prefetch count equal to 1000.

Describe alternatives you've considered

I find no alternatives, since to set the QoS we need to call a specific method on the amqp channel object. See https://pkg.go.dev/github.com/rabbitmq/amqp091-go#Channel.Qos

This development is not needed if we use the following configuration in the rabbitmq server: https://www.rabbitmq.com/docs/consumer-prefetch#default-limit

Additional context

Usuall we only set the consumer prefetch count, this is why I am ignoring the other parameters on the Qos method and setting default value.