这是indexloc提供的服务,不要输入任何密码
Skip to content

Commit e6294a1

Browse files
feat: support the protocol version in StreamingPullRequest (#1455)
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 716bb0b commit e6294a1

File tree

6 files changed

+39
-34
lines changed

6 files changed

+39
-34
lines changed

google/pubsub_v1/services/subscriber/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1897,7 +1897,7 @@ def request_generator():
18971897
# Wrappers in api-core should not automatically pre-fetch the first
18981898
# stream result, as this breaks the stream when re-opening it.
18991899
# https://github.com/googleapis/python-pubsub/issues/93#issuecomment-630762257
1900-
self._transport.streaming_pull._prefetch_first_result_ = False # type: ignore
1900+
self._transport.streaming_pull._prefetch_first_result_ = False
19011901

19021902
# Wrap the RPC method; this adds retry and timeout information,
19031903
# and friendly error handling.

google/pubsub_v1/types/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,12 @@
8787
Encoding,
8888
SchemaView,
8989
)
90-
import google.api_core.timeout
9190

9291
TimeoutType = Union[
9392
int,
9493
float,
95-
google.api_core.timeout.ConstantTimeout,
96-
google.api_core.timeout.ExponentialTimeout,
94+
"google.api_core.timeout.ConstantTimeout",
95+
"google.api_core.timeout.ExponentialTimeout",
9796
]
9897
"""The type of the timeout parameter of publisher client methods."""
9998

google/pubsub_v1/types/pubsub.py

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,13 @@ class State(proto.Enum):
241241
Permission denied encountered while consuming data from
242242
Kinesis. This can happen if:
243243
244-
- The provided ``aws_role_arn`` does not exist or does not
245-
have the appropriate permissions attached.
246-
- The provided ``aws_role_arn`` is not set up properly for
247-
Identity Federation using ``gcp_service_account``.
248-
- The Pub/Sub SA is not granted the
249-
``iam.serviceAccounts.getOpenIdToken`` permission on
250-
``gcp_service_account``.
244+
- The provided ``aws_role_arn`` does not exist or does not
245+
have the appropriate permissions attached.
246+
- The provided ``aws_role_arn`` is not set up properly for
247+
Identity Federation using ``gcp_service_account``.
248+
- The Pub/Sub SA is not granted the
249+
``iam.serviceAccounts.getOpenIdToken`` permission on
250+
``gcp_service_account``.
251251
PUBLISH_PERMISSION_DENIED (3):
252252
Permission denied encountered while publishing to the topic.
253253
This can happen if the Pub/Sub SA has not been granted the
@@ -347,9 +347,9 @@ class State(proto.Enum):
347347
granted the `appropriate
348348
permissions <https://cloud.google.com/storage/docs/access-control/iam-permissions>`__:
349349
350-
- storage.objects.list: to list the objects in a bucket.
351-
- storage.objects.get: to read the objects in a bucket.
352-
- storage.buckets.get: to verify the bucket exists.
350+
- storage.objects.list: to list the objects in a bucket.
351+
- storage.objects.get: to read the objects in a bucket.
352+
- storage.buckets.get: to verify the bucket exists.
353353
PUBLISH_PERMISSION_DENIED (3):
354354
Permission denied encountered while publishing to the topic.
355355
This can happen if the Pub/Sub SA has not been granted the
@@ -1991,11 +1991,11 @@ class Subscription(proto.Message):
19911991
for the delivery of a message with a given value of
19921992
``message_id`` on this subscription:
19931993
1994-
- The message sent to a subscriber is guaranteed not to be
1995-
resent before the message's acknowledgment deadline
1996-
expires.
1997-
- An acknowledged message will not be resent to a
1998-
subscriber.
1994+
- The message sent to a subscriber is guaranteed not to be
1995+
resent before the message's acknowledgment deadline
1996+
expires.
1997+
- An acknowledged message will not be resent to a
1998+
subscriber.
19991999
20002000
Note that subscribers may still receive multiple copies of a
20012001
message when ``enable_exactly_once_delivery`` is true if the
@@ -2309,10 +2309,10 @@ class PushConfig(proto.Message):
23092309
The only supported values for the ``x-goog-version``
23102310
attribute are:
23112311
2312-
- ``v1beta1``: uses the push format defined in the v1beta1
2313-
Pub/Sub API.
2314-
- ``v1`` or ``v1beta2``: uses the push format defined in
2315-
the v1 Pub/Sub API.
2312+
- ``v1beta1``: uses the push format defined in the v1beta1
2313+
Pub/Sub API.
2314+
- ``v1`` or ``v1beta2``: uses the push format defined in the
2315+
v1 Pub/Sub API.
23162316
23172317
For example: ``attributes { "x-goog-version": "v1" }``
23182318
oidc_token (google.pubsub_v1.types.PushConfig.OidcToken):
@@ -2478,12 +2478,11 @@ class State(proto.Enum):
24782478
Cannot write to the BigQuery table because of permission
24792479
denied errors. This can happen if
24802480
2481-
- Pub/Sub SA has not been granted the `appropriate BigQuery
2482-
IAM
2483-
permissions <https://cloud.google.com/pubsub/docs/create-subscription#assign_bigquery_service_account>`__
2484-
- bigquery.googleapis.com API is not enabled for the
2485-
project
2486-
(`instructions <https://cloud.google.com/service-usage/docs/enable-disable>`__)
2481+
- Pub/Sub SA has not been granted the `appropriate BigQuery
2482+
IAM
2483+
permissions <https://cloud.google.com/pubsub/docs/create-subscription#assign_bigquery_service_account>`__
2484+
- bigquery.googleapis.com API is not enabled for the project
2485+
(`instructions <https://cloud.google.com/service-usage/docs/enable-disable>`__)
24872486
NOT_FOUND (3):
24882487
Cannot write to the BigQuery table because it
24892488
does not exist.
@@ -3111,6 +3110,11 @@ class StreamingPullRequest(proto.Message):
31113110
only be set on the initial StreamingPullRequest. If it is
31123111
set on a subsequent request, the stream will be aborted with
31133112
status ``INVALID_ARGUMENT``.
3113+
protocol_version (int):
3114+
Optional. The protocol version used by the client. This
3115+
property can only be set on the initial
3116+
StreamingPullRequest. If it is set on a subsequent request,
3117+
the stream will be aborted with status ``INVALID_ARGUMENT``.
31143118
"""
31153119

31163120
subscription: str = proto.Field(
@@ -3145,6 +3149,10 @@ class StreamingPullRequest(proto.Message):
31453149
proto.INT64,
31463150
number=8,
31473151
)
3152+
protocol_version: int = proto.Field(
3153+
proto.INT64,
3154+
number=10,
3155+
)
31483156

31493157

31503158
class StreamingPullResponse(proto.Message):

mypy.ini

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
[mypy]
2-
python_version = 3.8
2+
python_version = 3.7
33
namespace_packages = True
4-
# Autogenerated folder - TODO remove this https://github.com/googleapis/python-pubsub/issues/536
5-
exclude = google/pubsub_v1

samples/generated_samples/snippet_metadata_google.pubsub.v1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-pubsub",
11-
"version": "2.31.1"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

scripts/fixup_pubsub_v1_keywords.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class pubsubCallTransformer(cst.CSTTransformer):
6868
'pull': ('subscription', 'max_messages', 'return_immediately', ),
6969
'rollback_schema': ('name', 'revision_id', ),
7070
'seek': ('subscription', 'time', 'snapshot', ),
71-
'streaming_pull': ('subscription', 'stream_ack_deadline_seconds', 'ack_ids', 'modify_deadline_seconds', 'modify_deadline_ack_ids', 'client_id', 'max_outstanding_messages', 'max_outstanding_bytes', ),
71+
'streaming_pull': ('subscription', 'stream_ack_deadline_seconds', 'ack_ids', 'modify_deadline_seconds', 'modify_deadline_ack_ids', 'client_id', 'max_outstanding_messages', 'max_outstanding_bytes', 'protocol_version', ),
7272
'update_snapshot': ('snapshot', 'update_mask', ),
7373
'update_subscription': ('subscription', 'update_mask', ),
7474
'update_topic': ('topic', 'update_mask', ),

0 commit comments

Comments
 (0)