Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Docs have inconsistent default values for max_latency and max_bytes #572

Merged
merged 4 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions docs/publisher/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ The way that this works is that on the first message that you send, a new batch
is created automatically. For every subsequent message, if there is already a
valid batch that is still accepting messages, then that batch is used. When the
batch is created, it begins a countdown that publishes the batch once
sufficient time has elapsed (by default, this is 0.05 seconds).
sufficient time has elapsed (by default, this is 0.01 seconds).

If you need different batching settings, simply provide a
:class:`~.pubsub_v1.types.BatchSettings` object when you instantiate the
Expand All @@ -84,11 +84,23 @@ If you need different batching settings, simply provide a
from google.cloud.pubsub import types

client = pubsub.PublisherClient(
batch_settings=types.BatchSettings(max_messages=500),
batch_settings=types.BatchSettings(
max_messages=500, # default 100
max_bytes=1024, # default 1 MB
anguillanneuf marked this conversation as resolved.
Show resolved Hide resolved
max_latency=1 # default .01 seconds
),
)

Pub/Sub accepts a maximum of 1,000 messages in a batch, and the size of a
batch can not exceed 10 megabytes.
The `max_bytes` argument is the maximum total size of the messages to collect
before automatically publishing the batch, (in bytes) including any byte size
overhead of the publish request itself. The maximum value is bound by the
server-side limit of 10_000_000 bytes. The default value is 1 MB.

The `max_messages` argument is the maximum number of messages to collect
before automatically publishing the batch, the default value is 100 messages.

The `max_latency` is the maximum number of seconds to wait for additional
messages before automatically publishing the batch, the default is .01 seconds.


Futures
Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def publish_messages_with_batch_settings(project_id: str, topic_id: str) -> None
# or 1 KiB of data, or 1 second has passed.
batch_settings = pubsub_v1.types.BatchSettings(
max_messages=10, # default 100
max_bytes=1024, # default 1 MiB
max_bytes=1024, # default 1 MB
anguillanneuf marked this conversation as resolved.
Show resolved Hide resolved
max_latency=1, # default 10 ms
)
publisher = pubsub_v1.PublisherClient(batch_settings)
Expand Down