@@ -128,6 +128,42 @@ You can also attach a callback to the future:
128128 future.add_done_callback(callback)
129129
130130
131+ Publish Flow Control
132+ --------------------
133+
134+ If publishing large amounts of messages or very large messages in quick
135+ succession, some of the publish requests might time out, especially if the
136+ bandwidth available is limited. To mitigate this the client can be
137+ configured with custom :class: `~.pubsub_v1.types.PublishFlowControl ` settings.
138+
139+ You can configure the maximum desired number of messages and their maximum total
140+ size, as well as the action that should be taken when the threshold is reached.
141+
142+ .. code-block :: python
143+
144+ from google.cloud import pubsub_v1
145+
146+ client = pubsub_v1.PublisherClient(
147+ publisher_options = pubsub_v1.types.PublisherOptions(
148+ flow_control = pubsub_v1.types.PublishFlowControl(
149+ message_limit = 500 ,
150+ byte_limit = 2 * 1024 * 1024 ,
151+ limit_exceeded_behavior = pubsub_v1.types.LimitExceededBehavior.BLOCK ,
152+ ),
153+ ),
154+ )
155+
156+ The action to be taken on overflow can be one of the following:
157+
158+ * :attr: `~.pubsub_v1.types.LimitExceededBehavior.IGNORE ` (default): Ignore the
159+ overflow and continue publishing the messages as normal.
160+ * :attr: `~.pubsub_v1.types.LimitExceededBehavior.ERROR `: Raise
161+ :exc: `~.pubsub_v1.publisher.exceptions.FlowControlLimitError ` and reject the message.
162+ * :attr: `~.pubsub_v1.types.LimitExceededBehavior.BLOCK `: Temporarily block in the
163+ :meth: `~.pubsub_v1.publisher.client.Client.publish ` method until there is
164+ enough capacity available.
165+
166+
131167API Reference
132168-------------
133169
0 commit comments