Skip to content

Commit 6a9a8e2

Browse files
anguillanneufplamut
authored andcommitted
remove publish concurrency control sample [(#2960)](GoogleCloudPlatform/python-docs-samples#2960)
1 parent a4319ed commit 6a9a8e2

File tree

3 files changed

+19
-55
lines changed

3 files changed

+19
-55
lines changed

samples/snippets/README.rst

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ To run this sample:
9393
$ python publisher.py
9494
9595
usage: publisher.py [-h]
96-
project
97-
{list,create,delete,publish,publish-with-custom-attributes,publish-with-futures,publish-with-batch-settings}
96+
project_id
97+
{list,create,delete,publish,publish-with-custom-attributes,publish-with-error-handler,publish-with-batch-settings,publish-with-retry-settings}
9898
...
9999
100100
This application demonstrates how to perform basic operations on topics
@@ -104,21 +104,23 @@ To run this sample:
104104
at https://cloud.google.com/pubsub/docs.
105105
106106
positional arguments:
107-
project Your Google Cloud project ID
108-
{list,create,delete,publish,publish-with-custom-attributes,publish-with-futures,publish-with-batch-settings}
107+
project_id Your Google Cloud project ID
108+
{list,create,delete,publish,publish-with-custom-attributes,publish-with-error-handler,publish-with-batch-settings,publish-with-retry-settings}
109109
list Lists all Pub/Sub topics in the given project.
110110
create Create a new Pub/Sub topic.
111111
delete Deletes an existing Pub/Sub topic.
112112
publish Publishes multiple messages to a Pub/Sub topic.
113113
publish-with-custom-attributes
114114
Publishes multiple messages with custom attributes to
115115
a Pub/Sub topic.
116-
publish-with-futures
117-
Publishes multiple messages to a Pub/Sub topic and
118-
prints their message IDs.
116+
publish-with-error-handler
117+
Publishes multiple messages to a Pub/Sub topic with an
118+
error handler.
119119
publish-with-batch-settings
120120
Publishes multiple messages to a Pub/Sub topic with
121121
batch settings.
122+
publish-with-retry-settings
123+
Publishes messages with custom retry settings.
122124
123125
optional arguments:
124126
-h, --help show this help message and exit
@@ -141,8 +143,8 @@ To run this sample:
141143
$ python subscriber.py
142144
143145
usage: subscriber.py [-h]
144-
project
145-
{list_in_topic,list_in_project,create,create-push,delete,update,receive,receive-custom-attributes,receive-flow-control,listen_for_errors}
146+
project_id
147+
{list_in_topic,list_in_project,create,create-push,delete,update,receive,receive-custom-attributes,receive-flow-control,receive-synchronously,receive-synchronously-with-lease,listen_for_errors}
146148
...
147149
148150
This application demonstrates how to perform basic operations on
@@ -152,26 +154,26 @@ To run this sample:
152154
at https://cloud.google.com/pubsub/docs.
153155
154156
positional arguments:
155-
project Your Google Cloud project ID
156-
{list_in_topic,list_in_project,create,create-push,delete,update,receive,receive-custom-attributes,receive-flow-control,listen_for_errors}
157+
project_id Your Google Cloud project ID
158+
{list_in_topic,list_in_project,create,create-push,delete,update,receive,receive-custom-attributes,receive-flow-control,receive-synchronously,receive-synchronously-with-lease,listen_for_errors}
157159
list_in_topic Lists all subscriptions for a given topic.
158160
list_in_project Lists all subscriptions in the current project.
159161
create Create a new pull subscription on the given topic.
160-
create-push Create a new push subscription on the given topic. For
161-
example, endpoint is "https://my-test-
162-
project.appspot.com/push".
162+
create-push Create a new push subscription on the given topic.
163163
delete Deletes an existing Pub/Sub topic.
164164
update Updates an existing Pub/Sub subscription's push
165165
endpoint URL. Note that certain properties of a
166166
subscription, such as its topic, are not modifiable.
167-
For example, endpoint is "https://my-test-
168-
project.appspot.com/push".
169167
receive Receives messages from a pull subscription.
170168
receive-custom-attributes
171169
Receives messages from a pull subscription.
172170
receive-flow-control
173171
Receives messages from a pull subscription with flow
174172
control.
173+
receive-synchronously
174+
Pulling messages synchronously.
175+
receive-synchronously-with-lease
176+
Pulling messages synchronously with lease management
175177
listen_for_errors Receives messages and catches errors from a pull
176178
subscription.
177179
@@ -244,4 +246,4 @@ to `browse the source`_ and `report issues`_.
244246
https://github.com/GoogleCloudPlatform/google-cloud-python/issues
245247
246248
247-
.. _Google Cloud SDK: https://cloud.google.com/sdk/
249+
.. _Google Cloud SDK: https://cloud.google.com/sdk/

samples/snippets/publisher.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -128,30 +128,6 @@ def publish_messages_with_custom_attributes(project_id, topic_name):
128128
# [END pubsub_publish_custom_attributes]
129129

130130

131-
def publish_messages_with_futures(project_id, topic_name):
132-
"""Publishes multiple messages to a Pub/Sub topic and prints their
133-
message IDs."""
134-
# [START pubsub_publisher_concurrency_control]
135-
from google.cloud import pubsub_v1
136-
137-
# TODO project_id = "Your Google Cloud Project ID"
138-
# TODO topic_name = "Your Pub/Sub topic name"
139-
140-
publisher = pubsub_v1.PublisherClient()
141-
topic_path = publisher.topic_path(project_id, topic_name)
142-
143-
for n in range(1, 10):
144-
data = u"Message number {}".format(n)
145-
# Data must be a bytestring
146-
data = data.encode("utf-8")
147-
# When you publish a message, the client returns a future.
148-
future = publisher.publish(topic_path, data=data)
149-
print(future.result())
150-
151-
print("Published messages with futures.")
152-
# [END pubsub_publisher_concurrency_control]
153-
154-
155131
def publish_messages_with_error_handler(project_id, topic_name):
156132
# [START pubsub_publish_messages_error_handler]
157133
"""Publishes multiple messages to a Pub/Sub topic with an error handler."""
@@ -308,11 +284,6 @@ def publish_messages_with_retry_settings(project_id, topic_name):
308284
)
309285
publish_with_custom_attributes_parser.add_argument("topic_name")
310286

311-
publish_with_futures_parser = subparsers.add_parser(
312-
"publish-with-futures", help=publish_messages_with_futures.__doc__
313-
)
314-
publish_with_futures_parser.add_argument("topic_name")
315-
316287
publish_with_error_handler_parser = subparsers.add_parser(
317288
"publish-with-error-handler",
318289
help=publish_messages_with_error_handler.__doc__,
@@ -345,8 +316,6 @@ def publish_messages_with_retry_settings(project_id, topic_name):
345316
publish_messages_with_custom_attributes(
346317
args.project_id, args.topic_name
347318
)
348-
elif args.command == "publish-with-futures":
349-
publish_messages_with_futures(args.project_id, args.topic_name)
350319
elif args.command == "publish-with-error-handler":
351320
publish_messages_with_error_handler(args.project_id, args.topic_name)
352321
elif args.command == "publish-with-batch-settings":

samples/snippets/publisher_test.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,3 @@ def test_publish_with_error_handler(topic_publish, capsys):
138138

139139
out, _ = capsys.readouterr()
140140
assert "Published" in out
141-
142-
143-
def test_publish_with_futures(topic_publish, capsys):
144-
publisher.publish_messages_with_futures(PROJECT, TOPIC_PUBLISH)
145-
146-
out, _ = capsys.readouterr()
147-
assert "Published" in out

0 commit comments

Comments
 (0)