-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Pubsub Could Use Autocreate on Topics and Subscriptions #905
Comments
@tmatsuo WDYT? |
Yeah, that seems convenient, although there are some caveats.
|
|
We had this same conversation at gcloud-node here. Basically what it boils down to is:
|
How is that lazy? That's a |
The alternative would be to check at construction or before a request. In On Tue, Jun 9, 2015, 4:43 PM Danny Hermes [email protected] wrote:
|
I agree, it's "lazy" in the sense that "we'll go based on the assumption that it exists" and a 404 means something different to that kind of topic. 404 to an autocreate topic means "go create the topic, then call the same thing again". |
@jonparrott Maybe I skimmed the You're saying behavior like this # foo does NOT exist
topic = Topic('foo', auto_create=True) # No HTTP request is sent
message = ...
topic.publish(message) # HTTP request results in 404, so first create and then publish and # foo DOES exist
topic = Topic('foo', auto_create=True) # No HTTP request is sent
message = ...
topic.publish(message) # HTTP request results in 200, confirmed the item exists Here is some issues I notice with the
|
I'm going to send a fix and we can discuss a bit there? |
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. |
I definitely overlooked "whereas looking before you leap means an extra request every single time." Thanks |
Closing. See #949 for context. |
I think this will be a recurring pattern:
So it might be a good idea to simplify it to:
gcloud-node
does something like this already.The text was updated successfully, but these errors were encountered: