Pubsub Could Use Autocreate on Topics and Subscriptions
See original GitHub issueI 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:
- Created 8 years ago
- Comments:12 (12 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Correct, but the failure case only happens once.
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.
The node one only tries to create once. If the creation method fails, it returns the error to the original callback.
Closing. See #949 for context.