Skip to content

Commit

Permalink
fix(pubsub): update batching and flow control parameters to be same a…
Browse files Browse the repository at this point in the history
…s the other client libraries (#9597)

* Update batching and flow control parameters to be same as the other client libraries.

* Fix tests

* Update test leaser param
  • Loading branch information
pradn authored and plamut committed Nov 11, 2019
1 parent 7f7d1b5 commit 6a46ac2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
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

0 comments on commit 6a46ac2

Please sign in to comment.