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

pubsub: default autoCreate:true #685

Conversation

stephenplusplus
Copy link
Contributor

Fixes #669

This privatizes createTopic by removing it from the docs and renaming it to createTopic_. It is still used internally with autoCreate: true, which is now true by default.

The other changes in this PR include doc/test changes to suit the new behavior, and refactoring how the autoCreate behavior is implemented (+ tests).

To Dos

  • publicize createTopic
  • add line to createTopic docs stating topic() is much easier, and likely what the user intends
  • fix doc issues mentioned by @ryanseys

@stephenplusplus stephenplusplus added the api: pubsub Issues related to the Pub/Sub API. label Jun 24, 2015
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jun 24, 2015
@stephenplusplus
Copy link
Contributor Author

@ryanseys sorry to disturb!, but curious of your thoughts on this one, mostly in terms of if privatizing createTopic and defaulting autoCreate to true sounds like a good plan? Thanks!

@jgeewax
Copy link
Contributor

jgeewax commented Jun 25, 2015 via email

@stephenplusplus
Copy link
Contributor Author

No rush at all! If this doesn't make it in by tomorrow, we can just pack it up in 0.17.0.

@ryanseys
Copy link
Contributor

Doesn't sound like a bad idea unless someone wants to create a lot of topics all the time... e.g. what if I'm making a public chatroom app and want to create a topic for each room being created? In this case, every request to use the topic will result in an extraneous request to attempt to use a non-existent topic first and could just not be the most efficient.

Have you considered leaving createTopic public, making autoCreate true by default and updating the createTopic docs to describe that the first time you try to use a topic it will auto create one by default anyway so you don't need to use the method except in certain cases? This would also allow the method to be more smoothly deprecated.


// Reference an existing topic.
var topic = pubsub.topic('my-existing-topic');
var topic = pubsub.topic('my-topic');

// Publish a message to the topic.

This comment was marked as spam.

This comment was marked as spam.

@ryanseys
Copy link
Contributor

Code looks good to me. Not against the idea, just definitely should consider all alternatives such as the one I mentioned above.

@stephenplusplus
Copy link
Contributor Author

Thanks, sir! I'm in favor of keeping the method public as well, but only for the reason that users would actually use it. I don't mind harshly deprecating it since we're still pre-stable.

@ryanseys
Copy link
Contributor

It's definitely not like we're getting rid of, or not supporting, the ability to create topics (that would be silly) so I don't see the need to hide it behind some private flag.

@stephenplusplus
Copy link
Contributor Author

createTopic('should we keep createTopic public?')

If @jgeewax agrees we should keep it public, I'll make the changes to the PR, fix the docs, and we can be on our mergy way.

@jgeewax
Copy link
Contributor

jgeewax commented Jun 25, 2015

Yea I can see the need to have createTopic as a method -- however I think the use case for it is much narrower (that the majority of people in a typical use case want .topic()), so we shouldn't really advertise it (or say in the docstring "You probably want .topic()").

Cool?

@stephenplusplus
Copy link
Contributor Author

Yeah. First post updated with todos.

@stephenplusplus stephenplusplus force-pushed the spp--pubsub-privatize-create-topic branch from c43f35f to cc38f88 Compare June 26, 2015 15:21
@stephenplusplus stephenplusplus changed the title pubsub: privatize createTopic + default autoCreate:true pubsub: default autoCreate:true Jun 26, 2015
@stephenplusplus stephenplusplus force-pushed the spp--pubsub-privatize-create-topic branch 3 times, most recently from 6e33489 to e5b52d5 Compare June 26, 2015 15:24
@stephenplusplus
Copy link
Contributor Author

To Dos have been To Done.


// Publish a message to the topic.
// The topic will be created if it doesn't exist.

This comment was marked as spam.

@stephenplusplus stephenplusplus force-pushed the spp--pubsub-privatize-create-topic branch from e5b52d5 to 2b9e1f9 Compare June 26, 2015 16:55
@@ -160,8 +160,16 @@ PubSub.prototype.getTopics = function(query, callback) {
*
* @example
* pubsub.createTopic('my-new-topic', function(err, topic, apiResponse) {
* topic.publish('New message!', function(err) {});
* topic.publish({

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@jgeewax
Copy link
Contributor

jgeewax commented Jun 26, 2015

Didn't spend too much time looking through but this looks pretty good to me 👍

stephenplusplus added a commit that referenced this pull request Jun 26, 2015
…eate-topic

pubsub: default autoCreate:true
@stephenplusplus stephenplusplus merged commit 560ea7e into googleapis:master Jun 26, 2015
@stephenplusplus
Copy link
Contributor Author

If anyone has doc improvements, we can iterate on them as we always do :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

createTopic vs topic can be confusing?
4 participants