Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: use new call syntax in subscriber docs #203

Merged
merged 2 commits into from
Sep 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions docs/subscriber/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ to subscribe to, and it must already exist. Once you have that, it is easy:
# your application.
sub_path = subscriber.subscription_path(PROJECT, SUBSCRIPTION)
topic_path = subscriber.topic_path(PROJECT, TOPIC)
subscriber.create_subscription(sub_path, topic_path)
subscriber.create_subscription(request={"name": sub_path, "topic": topic_path})

Once you have created a subscription (or if you already had one), the next
step is to pull data from it.
Expand All @@ -55,13 +55,23 @@ To pull the messages synchronously, use the client's
# Substitute PROJECT and SUBSCRIPTION with appropriate values for your
# application.
subscription_path = subscriber.subscription_path(PROJECT, SUBSCRIPTION)
response = subscriber.pull(subscription_path, max_messages=5)
response = subscriber.pull(
request={
"subscription": subscription_path,
"max_messages": 5,
}
)

for msg in response.received_messages:
print("Received message:", msg.message.data)

ack_ids = [msg.ack_id for msg in response.received_messages]
subscriber.acknowledge(subscription_path, ack_ids)
subscriber.acknowledge(
request={
"subscription": subscription_path,
"ack_ids": ack_ids,
}
)

The method returns a :class:`~.pubsub_v1.types.PullResponse` instance that
contains a list of received :class:`~.pubsub_v1.types.ReceivedMessage`
Expand All @@ -76,7 +86,13 @@ be dropped by this client and the backend will try to re-deliver them.

ack_ids = [] # TODO: populate with `ack_ids` of the messages to NACK
ack_deadline_seconds = 0
subscriber.modify_ack_deadline(subscription_path, ack_ids, ack_deadline_seconds)
subscriber.modify_ack_deadline(
request={
"subscription": subscription_path,
"ack_ids": ack_ids,
"ack_deadline_seconds": ack_deadline_seconds,
}
)


Pulling a Subscription Asynchronously
Expand Down