为现有订阅设置 flowControl 选项的正确方法是什么?

What is the proper way of setting flowControl options to existing subscription?

文档没有说明,将现有订阅与 @google-cloud/pubsub@0.14.x

一起使用的正确方法是什么

可以使用 topic.getSubscriptions() 接收订阅,但似乎没有什么方法可以为接收的订阅设置订阅流控制选项。

另外 topic.createSubscription() 似乎 return 现有订阅如果找到并且有可能传递选项对象。

那么,有没有一种方法可以为收到的订阅设置 flowControl 选项,或者 createSubscription 就是为了这个目的?

在节点库中"subscription"可以参考两个东西之一。它可以引用 Cloud Pub/Sub 实体,它是对某个主题的消息感兴趣的逻辑实体。它还可以指在逻辑订阅上接收消息的工作人员。我们也将此工作者称为 "subscriber." 可以有零个或多个订阅者 运行 同时接收订阅消息。如果有多个订阅者,则消息会在他们之间进行负载平衡。

流量控制是 属性 工作人员的,而不是云 Pub/Sub 订阅。在documentation for a subscription, it states "note that [flow control] options do not persist across subscription instances." The createSubscription method should be used to set flow control settings on a worker. If the subscription entity already exists in Cloud Pub/Sub, then it will not be recreated. The worker created by createSubscription will use this subscription and apply the flow control settings that are specified. The message flow control example中演示了如何设置属性。