61
61
# these settings can be altered to tweak Pub/Sub behavior.
62
62
# The defaults should be fine for most use cases.
63
63
class BatchSettings (NamedTuple ):
64
- """The settings for batch publishing the messages."""
64
+ """The settings for batch publishing the messages.
65
+
66
+ Attributes:
67
+ max_bytes (int):
68
+ The maximum total size of the messages to collect before automatically
69
+ publishing the batch, including any byte size overhead of the publish
70
+ request itself. The maximum value is bound by the server-side limit of
71
+ 10_000_000 bytes. Defaults to 1 MB.
72
+ max_latency (float):
73
+ The maximum number of seconds to wait for additional messages before
74
+ automatically publishing the batch. Defaults to 10ms.
75
+ max_messages (int):
76
+ The maximum number of messages to collect before automatically
77
+ publishing the batch. Defaults to 100.
78
+ """
65
79
66
80
max_bytes : int = 1 * 1000 * 1000 # 1 MB
67
81
(
@@ -93,7 +107,19 @@ class LimitExceededBehavior(str, enum.Enum):
93
107
94
108
95
109
class PublishFlowControl (NamedTuple ):
96
- """The client flow control settings for message publishing."""
110
+ """The client flow control settings for message publishing.
111
+
112
+ Attributes:
113
+ message_limit (int):
114
+ The maximum number of messages awaiting to be published.
115
+ Defaults to 1000.
116
+ byte_limit (int):
117
+ The maximum total size of messages awaiting to be published.
118
+ Defaults to 10MB.
119
+ limit_exceeded_behavior (LimitExceededBehavior):
120
+ The action to take when publish flow control limits are exceeded.
121
+ Defaults to LimitExceededBehavior.IGNORE.
122
+ """
97
123
98
124
message_limit : int = 10 * BatchSettings .__new__ .__defaults__ [2 ] # type: ignore
99
125
"""The maximum number of messages awaiting to be published."""
@@ -110,7 +136,22 @@ class PublishFlowControl(NamedTuple):
110
136
# This class is used when creating a publisher client to pass in options
111
137
# to enable/disable features.
112
138
class PublisherOptions (NamedTuple ):
113
- """The options for the publisher client."""
139
+ """The options for the publisher client.
140
+
141
+ Attributes:
142
+ enable_message_ordering (bool):
143
+ Whether to order messages in a batch by a supplied ordering key.
144
+ Defaults to false.
145
+ flow_control (PublishFlowControl):
146
+ Flow control settings for message publishing by the client. By default
147
+ the publisher client does not do any throttling.
148
+ retry (OptionalRetry):
149
+ Retry settings for message publishing by the client. This should be
150
+ an instance of :class:`google.api_core.retry.Retry`.
151
+ timeout (OptionalTimeout):
152
+ Timeout settings for message publishing by the client. It should be
153
+ compatible with :class:`~.pubsub_v1.types.TimeoutType`.
154
+ """
114
155
115
156
enable_message_ordering : bool = False
116
157
"""Whether to order messages in a batch by a supplied ordering key."""
@@ -142,6 +183,26 @@ class PublisherOptions(NamedTuple):
142
183
class FlowControl (NamedTuple ):
143
184
"""The settings for controlling the rate at which messages are pulled
144
185
with an asynchronous subscription.
186
+
187
+ Attributes:
188
+ max_bytes (int):
189
+ The maximum total size of received - but not yet processed - messages
190
+ before pausing the message stream. Defaults to 100 MiB.
191
+ max_messages (int):
192
+ The maximum number of received - but not yet processed - messages before
193
+ pausing the message stream. Defaults to 1000.
194
+ max_lease_duration (float):
195
+ The maximum amount of time in seconds to hold a lease on a message
196
+ before dropping it from the lease management. Defaults to 1 hour.
197
+ min_duration_per_lease_extension (float):
198
+ The min amount of time in seconds for a single lease extension attempt.
199
+ Must be between 10 and 600 (inclusive). Ignored by default, but set to
200
+ 60 seconds if the subscription has exactly-once delivery enabled.
201
+ max_duration_per_lease_extension (float):
202
+ The max amount of time in seconds for a single lease extension attempt.
203
+ Bounds the delay before a message redelivery if the subscriber
204
+ fails to extend the deadline. Must be between 10 and 600 (inclusive). Ignored
205
+ if set to 0.
145
206
"""
146
207
147
208
max_bytes : int = 100 * 1024 * 1024 # 100 MiB
0 commit comments