question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pubsub Could Use Autocreate on Topics and Subscriptions

See original GitHub issue

I think this will be a recurring pattern:

topic = pubsub.Topic('book-process-queue')
if not topic.exists():
    topic.create()

subscription = pubsub.Subscription('book-sub', topic)
if not subscription.exists():
    subscription.create()

So it might be a good idea to simplify it to:

topic = pubsub.Topic('book-process-queue', auto_create=True)

gcloud-node does something like this already.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
theacodescommented, Jun 10, 2015

In the failure case, publish results in 3 requests

Correct, but the failure case only happens once.

We could just as well do a create requests.

You could, but you would need to do this every time the item is constructed.

The trade off is that assuming it exists and handling the failure cases results in 2 extra requests once, whereas looking before you leap means an extra request every single time.

In other words, a 404 for another reason should not trigger the create request

The node one only tries to create once. If the creation method fails, it returns the error to the original callback.

0reactions
dhermescommented, Jun 30, 2015

Closing. See #949 for context.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create and use topics | Cloud Pub/Sub Documentation
In the Google Cloud console, go to the Pub/Sub Topics page. Go to Topics. Click Create topic. In the Topic ID field, enter...
Read more >
Creating a Topic with Pub/Sub in Google Cloud
From Google Cloud console's main navigation, choose Pub/Sub. · Click Create a Topic. · Give your topic a name, click Create Topic. ·...
Read more >
Google Pub/Sub Basics - Reputation Developers
Topic and subscription can be created in the following ways ... auto wired PubSubAdmin class bean can be used to create and manage...
Read more >
Permissions for creating a subscription - Google Groups
It seems like a common intended usage of pubsub is for a consumer to create its own subscription when it starts up. ......
Read more >
Subscribe to Events | Device Access - Google Developers
Subscribe to and manage Google Cloud Pub/Sub events and provide ... need it to create a subscription to the topic so event messages...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found