Many ways to construct a Subscription without specifying message receipt options #247
Labels
api: pubsub
Issues related to the googleapis/nodejs-pubsub API.
priority: p1
Important issue which blocks shipping the next release. Will be fixed prior to next release.
🚨
This issue needs some love.
triaged for GA
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
The Subscription constructor takes an important options argument for configuring the receipt of messages: aka batching/flow control
https://cloud.google.com/nodejs/docs/reference/pubsub/0.19.x/Subscription#Subscription
But there are many ways to get a Subscription object without having the ability to specify these options:
https://cloud.google.com/nodejs/docs/reference/pubsub/0.19.x/v1.SubscriberClient#createSubscription (note these are a different set options that are required for the CreateSubscription call, but not for configuring the reciept of messages)
https://cloud.google.com/nodejs/docs/reference/pubsub/0.19.x/v1.SubscriberClient#getSubscription
https://cloud.google.com/nodejs/docs/reference/pubsub/0.19.x/v1.SubscriberClient#listSubscriptions
The Python library does this better... it decouples the Subscription as a noun from the verb of subscribing. Instead of taking these options in via constructor argument, a subscribe method is provided that takes these options: https://googlecloudplatform.github.io/google-cloud-python/latest/pubsub/subscriber/api/client.html#google.cloud.pubsub_v1.subscriber.client.Client.subscribe
However, this can't work given the way things are currently structured in the Javascript library, because the Subscription object is an EventEmitter. Therefore, a Subscription cannot exist without being already configured to receive messages. Alternately, you could make the Subscription object not be an EventEmitter, and (similar to Python) add a subscribe method that takes configuration and returns an EventEmitter.
The text was updated successfully, but these errors were encountered: