From 9f774facec45ac213e39bb45d5eddb760c9d2f78 Mon Sep 17 00:00:00 2001 From: Anna Cocuzzo <63511057+acocuzzo@users.noreply.github.com> Date: Thu, 18 May 2023 15:27:40 -0400 Subject: [PATCH 1/6] Docs: Add Attributes to pubsub_v1.types --- google/cloud/pubsub_v1/types.py | 67 +++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/google/cloud/pubsub_v1/types.py b/google/cloud/pubsub_v1/types.py index 109d4aadc..fc6d708a5 100644 --- a/google/cloud/pubsub_v1/types.py +++ b/google/cloud/pubsub_v1/types.py @@ -61,7 +61,20 @@ # these settings can be altered to tweak Pub/Sub behavior. # The defaults should be fine for most use cases. class BatchSettings(NamedTuple): - """The settings for batch publishing the messages.""" + r"""The settings for batch publishing the messages. + Attributes: + max_bytes (int): + The maximum total size of the messages to collect before automatically + publishing the batch, 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. Defaults to 1 MB. + max_latency (float): + The maximum number of seconds to wait for additional messages before + automatically publishing the batch. Defaults to 10ms. + max_messages (int): + The maximum number of messages to collect before automatically + publishing the batch. Defaults to 100. + """ max_bytes: int = 1 * 1000 * 1000 # 1 MB ( @@ -93,7 +106,18 @@ class LimitExceededBehavior(str, enum.Enum): class PublishFlowControl(NamedTuple): - """The client flow control settings for message publishing.""" + r"""The client flow control settings for message publishing. + Attributes: + message_limit (int): + The maximum number of messages awaiting to be published. + Defaults to 1000. + byte_limit (int): + The maximum total size of messages awaiting to be published. + Defaults to 10MB. + limit_exceeded_behavior (LimitExceededBehavior): + The action to take when publish flow control limits are exceeded. + Defaults to LimitExceededBehavior.IGNORE. + """ message_limit: int = 10 * BatchSettings.__new__.__defaults__[2] # type: ignore """The maximum number of messages awaiting to be published.""" @@ -110,7 +134,22 @@ class PublishFlowControl(NamedTuple): # This class is used when creating a publisher client to pass in options # to enable/disable features. class PublisherOptions(NamedTuple): - """The options for the publisher client.""" + """The options for the publisher client. + + Attributes: + enable_message_ordering (bool): + Whether to order messages in a batch by a supplied ordering key. + Defaults to false. + flow_control (PublishFlowControl): + Flow control settings for message publishing by the client. By default + the publisher client does not do any throttling. + retry ("OptionalRetry"): + Retry settings for message publishing by the client. This should be + an instance of :class:`google.api_core.retry.Retry`. + timeout ("OptionalTimeout"): + Timeout settings for message publishing by the client. It should be + compatible with :class:`~.pubsub_v1.types.TimeoutType`. + """ enable_message_ordering: bool = False """Whether to order messages in a batch by a supplied ordering key.""" @@ -140,8 +179,28 @@ class PublisherOptions(NamedTuple): # these settings can be altered to tweak Pub/Sub behavior. # The defaults should be fine for most use cases. class FlowControl(NamedTuple): - """The settings for controlling the rate at which messages are pulled + r"""The settings for controlling the rate at which messages are pulled with an asynchronous subscription. + + Attributes: + max_bytes (int): + The maximum total size of received - but not yet processed - messages + before pausing the message stream. Defaults to 100 MiB. + max_messages (int): + The maximum number of received - but not yet processed - messages before + pausing the message stream. Defaults to 1000. + max_lease_duration (float): + The maximum amount of time in seconds to hold a lease on a message + before dropping it from the lease management. Defaults to 1 hour. + min_duration_per_lease_extension (float): + The min amount of time in seconds for a single lease extension attempt. + Must be between 10 and 600 (inclusive). Ignored by default, but set to + 60 seconds if the subscription has exactly-once delivery enabled. + max_duration_per_lease_extension (float): + The max amount of time in seconds for a single lease extension attempt. + Bounds the delay before a message redelivery if the subscriber + fails to extend the deadline. Must be between 10 and 600 (inclusive). Ignored + if set to 0. """ max_bytes: int = 100 * 1024 * 1024 # 100 MiB From 0e02b4eaab5f5abd8e6a76907144f1cf36c5e9d7 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 18 May 2023 19:33:08 +0000 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- google/cloud/pubsub_v1/types.py | 50 ++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/google/cloud/pubsub_v1/types.py b/google/cloud/pubsub_v1/types.py index fc6d708a5..5c99ba5a6 100644 --- a/google/cloud/pubsub_v1/types.py +++ b/google/cloud/pubsub_v1/types.py @@ -62,18 +62,18 @@ # The defaults should be fine for most use cases. class BatchSettings(NamedTuple): r"""The settings for batch publishing the messages. - Attributes: - max_bytes (int): - The maximum total size of the messages to collect before automatically - publishing the batch, 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. Defaults to 1 MB. - max_latency (float): - The maximum number of seconds to wait for additional messages before - automatically publishing the batch. Defaults to 10ms. - max_messages (int): - The maximum number of messages to collect before automatically - publishing the batch. Defaults to 100. + Attributes: + max_bytes (int): + The maximum total size of the messages to collect before automatically + publishing the batch, 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. Defaults to 1 MB. + max_latency (float): + The maximum number of seconds to wait for additional messages before + automatically publishing the batch. Defaults to 10ms. + max_messages (int): + The maximum number of messages to collect before automatically + publishing the batch. Defaults to 100. """ max_bytes: int = 1 * 1000 * 1000 # 1 MB @@ -136,19 +136,19 @@ class PublishFlowControl(NamedTuple): class PublisherOptions(NamedTuple): """The options for the publisher client. - Attributes: - enable_message_ordering (bool): - Whether to order messages in a batch by a supplied ordering key. - Defaults to false. - flow_control (PublishFlowControl): - Flow control settings for message publishing by the client. By default - the publisher client does not do any throttling. - retry ("OptionalRetry"): - Retry settings for message publishing by the client. This should be - an instance of :class:`google.api_core.retry.Retry`. - timeout ("OptionalTimeout"): - Timeout settings for message publishing by the client. It should be - compatible with :class:`~.pubsub_v1.types.TimeoutType`. + Attributes: + enable_message_ordering (bool): + Whether to order messages in a batch by a supplied ordering key. + Defaults to false. + flow_control (PublishFlowControl): + Flow control settings for message publishing by the client. By default + the publisher client does not do any throttling. + retry ("OptionalRetry"): + Retry settings for message publishing by the client. This should be + an instance of :class:`google.api_core.retry.Retry`. + timeout ("OptionalTimeout"): + Timeout settings for message publishing by the client. It should be + compatible with :class:`~.pubsub_v1.types.TimeoutType`. """ enable_message_ordering: bool = False From e72505c2af2926609785ab237e2fe61375e84b1b Mon Sep 17 00:00:00 2001 From: Anna Cocuzzo <63511057+acocuzzo@users.noreply.github.com> Date: Thu, 18 May 2023 20:08:39 +0000 Subject: [PATCH 3/6] fix lint --- google/cloud/pubsub_v1/types.py | 50 ++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/google/cloud/pubsub_v1/types.py b/google/cloud/pubsub_v1/types.py index fc6d708a5..5c99ba5a6 100644 --- a/google/cloud/pubsub_v1/types.py +++ b/google/cloud/pubsub_v1/types.py @@ -62,18 +62,18 @@ # The defaults should be fine for most use cases. class BatchSettings(NamedTuple): r"""The settings for batch publishing the messages. - Attributes: - max_bytes (int): - The maximum total size of the messages to collect before automatically - publishing the batch, 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. Defaults to 1 MB. - max_latency (float): - The maximum number of seconds to wait for additional messages before - automatically publishing the batch. Defaults to 10ms. - max_messages (int): - The maximum number of messages to collect before automatically - publishing the batch. Defaults to 100. + Attributes: + max_bytes (int): + The maximum total size of the messages to collect before automatically + publishing the batch, 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. Defaults to 1 MB. + max_latency (float): + The maximum number of seconds to wait for additional messages before + automatically publishing the batch. Defaults to 10ms. + max_messages (int): + The maximum number of messages to collect before automatically + publishing the batch. Defaults to 100. """ max_bytes: int = 1 * 1000 * 1000 # 1 MB @@ -136,19 +136,19 @@ class PublishFlowControl(NamedTuple): class PublisherOptions(NamedTuple): """The options for the publisher client. - Attributes: - enable_message_ordering (bool): - Whether to order messages in a batch by a supplied ordering key. - Defaults to false. - flow_control (PublishFlowControl): - Flow control settings for message publishing by the client. By default - the publisher client does not do any throttling. - retry ("OptionalRetry"): - Retry settings for message publishing by the client. This should be - an instance of :class:`google.api_core.retry.Retry`. - timeout ("OptionalTimeout"): - Timeout settings for message publishing by the client. It should be - compatible with :class:`~.pubsub_v1.types.TimeoutType`. + Attributes: + enable_message_ordering (bool): + Whether to order messages in a batch by a supplied ordering key. + Defaults to false. + flow_control (PublishFlowControl): + Flow control settings for message publishing by the client. By default + the publisher client does not do any throttling. + retry ("OptionalRetry"): + Retry settings for message publishing by the client. This should be + an instance of :class:`google.api_core.retry.Retry`. + timeout ("OptionalTimeout"): + Timeout settings for message publishing by the client. It should be + compatible with :class:`~.pubsub_v1.types.TimeoutType`. """ enable_message_ordering: bool = False From bded1c745433325a0687cae79fd39671d6e43f02 Mon Sep 17 00:00:00 2001 From: Anna Cocuzzo <63511057+acocuzzo@users.noreply.github.com> Date: Thu, 18 May 2023 20:14:08 +0000 Subject: [PATCH 4/6] fix indent --- google/cloud/pubsub_v1/types.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/google/cloud/pubsub_v1/types.py b/google/cloud/pubsub_v1/types.py index 5c99ba5a6..5cf56bbb6 100644 --- a/google/cloud/pubsub_v1/types.py +++ b/google/cloud/pubsub_v1/types.py @@ -62,6 +62,7 @@ # The defaults should be fine for most use cases. class BatchSettings(NamedTuple): r"""The settings for batch publishing the messages. + Attributes: max_bytes (int): The maximum total size of the messages to collect before automatically @@ -107,6 +108,7 @@ class LimitExceededBehavior(str, enum.Enum): class PublishFlowControl(NamedTuple): r"""The client flow control settings for message publishing. + Attributes: message_limit (int): The maximum number of messages awaiting to be published. From fd066a8d0140b8a9ae968528869dfdeee80f85bd Mon Sep 17 00:00:00 2001 From: Anna Cocuzzo <63511057+acocuzzo@users.noreply.github.com> Date: Thu, 18 May 2023 17:21:35 -0400 Subject: [PATCH 5/6] Apply suggestions from code review Co-authored-by: Dan Lee <71398022+dandhlee@users.noreply.github.com> --- google/cloud/pubsub_v1/types.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/google/cloud/pubsub_v1/types.py b/google/cloud/pubsub_v1/types.py index 5cf56bbb6..4121ca02a 100644 --- a/google/cloud/pubsub_v1/types.py +++ b/google/cloud/pubsub_v1/types.py @@ -61,7 +61,7 @@ # these settings can be altered to tweak Pub/Sub behavior. # The defaults should be fine for most use cases. class BatchSettings(NamedTuple): - r"""The settings for batch publishing the messages. + """The settings for batch publishing the messages. Attributes: max_bytes (int): @@ -107,7 +107,7 @@ class LimitExceededBehavior(str, enum.Enum): class PublishFlowControl(NamedTuple): - r"""The client flow control settings for message publishing. + """The client flow control settings for message publishing. Attributes: message_limit (int): @@ -145,10 +145,10 @@ class PublisherOptions(NamedTuple): flow_control (PublishFlowControl): Flow control settings for message publishing by the client. By default the publisher client does not do any throttling. - retry ("OptionalRetry"): + retry (OptionalRetry): Retry settings for message publishing by the client. This should be an instance of :class:`google.api_core.retry.Retry`. - timeout ("OptionalTimeout"): + timeout (OptionalTimeout): Timeout settings for message publishing by the client. It should be compatible with :class:`~.pubsub_v1.types.TimeoutType`. """ From 151aad279862477b7a03279ce8e2675b5f24d913 Mon Sep 17 00:00:00 2001 From: Anna Cocuzzo <63511057+acocuzzo@users.noreply.github.com> Date: Thu, 18 May 2023 17:22:05 -0400 Subject: [PATCH 6/6] Apply suggestions from code review Co-authored-by: Dan Lee <71398022+dandhlee@users.noreply.github.com> --- google/cloud/pubsub_v1/types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/google/cloud/pubsub_v1/types.py b/google/cloud/pubsub_v1/types.py index 4121ca02a..3d071a189 100644 --- a/google/cloud/pubsub_v1/types.py +++ b/google/cloud/pubsub_v1/types.py @@ -181,7 +181,7 @@ class PublisherOptions(NamedTuple): # these settings can be altered to tweak Pub/Sub behavior. # The defaults should be fine for most use cases. class FlowControl(NamedTuple): - r"""The settings for controlling the rate at which messages are pulled + """The settings for controlling the rate at which messages are pulled with an asynchronous subscription. Attributes: @@ -192,7 +192,7 @@ class FlowControl(NamedTuple): The maximum number of received - but not yet processed - messages before pausing the message stream. Defaults to 1000. max_lease_duration (float): - The maximum amount of time in seconds to hold a lease on a message + The maximum amount of time in seconds to hold a lease on a message before dropping it from the lease management. Defaults to 1 hour. min_duration_per_lease_extension (float): The min amount of time in seconds for a single lease extension attempt.