Skip to content

Commit c5eba0f

Browse files
pradnplamut
authored andcommitted
fix(pubsub): update batching and flow control parameters to be same as 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
1 parent bd92594 commit c5eba0f

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

packages/google-cloud-pubsub/google/cloud/pubsub_v1/types.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
"BatchSettings", ["max_bytes", "max_latency", "max_messages"]
4040
)
4141
BatchSettings.__new__.__defaults__ = (
42-
1000 * 1000 * 10, # max_bytes: documented "10 MB", enforced 10000000
43-
0.05, # max_latency: 0.05 seconds
44-
1000, # max_messages: 1,000
42+
1 * 1000 * 1000, # max_bytes: 1 MB
43+
0.01, # max_latency: 10 ms
44+
100, # max_messages: 100
4545
)
4646

4747
if sys.version_info >= (3, 5):
@@ -70,8 +70,8 @@
7070
)
7171
FlowControl.__new__.__defaults__ = (
7272
100 * 1024 * 1024, # max_bytes: 100mb
73-
100, # max_messages: 100
74-
2 * 60 * 60, # max_lease_duration: 2 hours.
73+
1000, # max_messages: 1000
74+
1 * 60 * 60, # max_lease_duration: 1 hour.
7575
)
7676

7777
if sys.version_info >= (3, 5):

packages/google-cloud-pubsub/tests/unit/pubsub_v1/publisher/test_publisher_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def test_init():
3131
# A plain client should have an `api` (the underlying GAPIC) and a
3232
# batch settings object, which should have the defaults.
3333
assert isinstance(client.api, publisher_client.PublisherClient)
34-
assert client.batch_settings.max_bytes == 10 * 1000 * 1000
35-
assert client.batch_settings.max_latency == 0.05
36-
assert client.batch_settings.max_messages == 1000
34+
assert client.batch_settings.max_bytes == 1 * 1000 * 1000
35+
assert client.batch_settings.max_latency == 0.01
36+
assert client.batch_settings.max_messages == 100
3737

3838

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

5151

5252
def test_init_emulator(monkeypatch):

packages/google-cloud-pubsub/tests/unit/pubsub_v1/subscriber/test_streaming_pull_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,9 @@ def test__on_response_with_leaser_overload():
660660
]
661661
)
662662

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

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

0 commit comments

Comments
 (0)