22
33from google .api_core .client_options import ClientOptions
44from google .auth .credentials import Credentials
5+ from google .cloud .pubsub_v1 .types import BatchSettings
56
67from google .cloud .pubsublite .cloudpubsub .internal .async_publisher_impl import (
78 AsyncPublisherImpl ,
1011from google .cloud .pubsublite .cloudpubsub .publisher import AsyncPublisher , Publisher
1112from google .cloud .pubsublite .internal .wire .make_publisher import (
1213 make_publisher as make_wire_publisher ,
14+ DEFAULT_BATCHING_SETTINGS as WIRE_DEFAULT_BATCHING ,
1315)
1416from google .cloud .pubsublite .internal .wire .merge_metadata import merge_metadata
1517from google .cloud .pubsublite .internal .wire .pubsub_context import pubsub_context
1618from google .cloud .pubsublite .paths import TopicPath
1719
1820
21+ DEFAULT_BATCHING_SETTINGS = WIRE_DEFAULT_BATCHING
22+
23+
1924def make_async_publisher (
2025 topic : TopicPath ,
21- batching_delay_secs : Optional [float ] = None ,
26+ per_partition_batching_settings : Optional [BatchSettings ] = None ,
2227 credentials : Optional [Credentials ] = None ,
2328 client_options : Optional [ClientOptions ] = None ,
2429 metadata : Optional [Mapping [str , str ]] = None ,
@@ -28,7 +33,7 @@ def make_async_publisher(
2833
2934 Args:
3035 topic: The topic to publish to.
31- batching_delay_secs: The delay in seconds to batch messages . The default is reasonable for most cases.
36+ per_partition_batching_settings: Settings for batching messages on each partition . The default is reasonable for most cases.
3237 credentials: The credentials to use to connect. GOOGLE_DEFAULT_CREDENTIALS is used if None.
3338 client_options: Other options to pass to the client. Note that if you pass any you must set api_endpoint.
3439 metadata: Additional metadata to send with the RPC.
@@ -43,15 +48,19 @@ def make_async_publisher(
4348
4449 def underlying_factory ():
4550 return make_wire_publisher (
46- topic , batching_delay_secs , credentials , client_options , metadata
51+ topic ,
52+ per_partition_batching_settings ,
53+ credentials ,
54+ client_options ,
55+ metadata ,
4756 )
4857
4958 return AsyncPublisherImpl (underlying_factory )
5059
5160
5261def make_publisher (
5362 topic : TopicPath ,
54- batching_delay_secs : Optional [float ] = None ,
63+ per_partition_batching_settings : Optional [BatchSettings ] = None ,
5564 credentials : Optional [Credentials ] = None ,
5665 client_options : Optional [ClientOptions ] = None ,
5766 metadata : Optional [Mapping [str , str ]] = None ,
@@ -61,7 +70,7 @@ def make_publisher(
6170
6271 Args:
6372 topic: The topic to publish to.
64- batching_delay_secs: The delay in seconds to batch messages . The default is reasonable for most cases.
73+ per_partition_batching_settings: Settings for batching messages on each partition . The default is reasonable for most cases.
6574 credentials: The credentials to use to connect. GOOGLE_DEFAULT_CREDENTIALS is used if None.
6675 client_options: Other options to pass to the client. Note that if you pass any you must set api_endpoint.
6776 metadata: Additional metadata to send with the RPC.
@@ -74,6 +83,10 @@ def make_publisher(
7483 """
7584 return PublisherImpl (
7685 make_async_publisher (
77- topic , batching_delay_secs , credentials , client_options , metadata
86+ topic ,
87+ per_partition_batching_settings ,
88+ credentials ,
89+ client_options ,
90+ metadata ,
7891 )
7992 )
0 commit comments