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

fix(pubsub): update batching and flow control parameters to be same as the other client libraries #9597

Merged
merged 3 commits into from
Nov 11, 2019
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
10 changes: 5 additions & 5 deletions pubsub/google/cloud/pubsub_v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
"BatchSettings", ["max_bytes", "max_latency", "max_messages"]
)
BatchSettings.__new__.__defaults__ = (
1000 * 1000 * 10, # max_bytes: documented "10 MB", enforced 10000000
0.05, # max_latency: 0.05 seconds
1000, # max_messages: 1,000
1 * 1000 * 1000, # max_bytes: 1 MB
0.01, # max_latency: 10 ms
100, # max_messages: 100
)

if sys.version_info >= (3, 5):
Expand Down Expand Up @@ -70,8 +70,8 @@
)
FlowControl.__new__.__defaults__ = (
100 * 1024 * 1024, # max_bytes: 100mb
100, # max_messages: 100
2 * 60 * 60, # max_lease_duration: 2 hours.
1000, # max_messages: 1000
1 * 60 * 60, # max_lease_duration: 1 hour.
)

if sys.version_info >= (3, 5):
Expand Down
12 changes: 6 additions & 6 deletions pubsub/tests/unit/pubsub_v1/publisher/test_publisher_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def test_init():
# A plain client should have an `api` (the underlying GAPIC) and a
# batch settings object, which should have the defaults.
assert isinstance(client.api, publisher_client.PublisherClient)
assert client.batch_settings.max_bytes == 10 * 1000 * 1000
assert client.batch_settings.max_latency == 0.05
assert client.batch_settings.max_messages == 1000
assert client.batch_settings.max_bytes == 1 * 1000 * 1000
assert client.batch_settings.max_latency == 0.01
assert client.batch_settings.max_messages == 100


def test_init_w_custom_transport():
Expand All @@ -44,9 +44,9 @@ def test_init_w_custom_transport():
# batch settings object, which should have the defaults.
assert isinstance(client.api, publisher_client.PublisherClient)
assert client.api.transport is transport
assert client.batch_settings.max_bytes == 10 * 1000 * 1000
assert client.batch_settings.max_latency == 0.05
assert client.batch_settings.max_messages == 1000
assert client.batch_settings.max_bytes == 1 * 1000 * 1000
assert client.batch_settings.max_latency == 0.01
assert client.batch_settings.max_messages == 100


def test_init_emulator(monkeypatch):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,9 @@ def test__on_response_with_leaser_overload():
]
)

# Adjust message bookkeeping in leaser. Pick 99 messages, which is just below
# Adjust message bookkeeping in leaser. Pick 999 messages, which is just below
# the default FlowControl.max_messages limit.
fake_leaser_add(leaser, init_msg_count=99, init_bytes=990)
fake_leaser_add(leaser, init_msg_count=999, init_bytes=9900)

# Actually run the method and prove that modack and schedule
# are called in the expected way.
Expand Down