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: allow simple publishing #1662

Merged
merged 2 commits into from
Oct 10, 2016

Conversation

stephenplusplus
Copy link
Contributor

@stephenplusplus stephenplusplus commented Oct 3, 2016

Fixes #629

⚠️ Breaking Change

Before

topic.publish({
  data: {
    hi: 'there'
  }
}, function(err, messageIds, apiResponse) {});

After

topic.publish({
  hi: 'there'
}, function(err, messageIds, apiResponse) {});

Accepts any data type

topic.publish('Hi there', function(err, messageIds, apiResponse) {});

To set attributes

topic.publish({
  data: {
    hi: 'there'
  },
  attributes: {
    key: 'value'
  }
}, { raw: true }, function(err, messageIds, apiResponse) {});

The easiest way to make your code compatible

Provide an options object with raw: true.

var message = {
  data: 'my old data'
};

-topic.publish(message, function(err, messageIds, apiResponse) {});
+topic.publish(message, { raw: true }, function(err, messageIds, apiResponse) {});

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 3, 2016
@stephenplusplus stephenplusplus added the api: pubsub Issues related to the Pub/Sub API. label Oct 3, 2016
@callmehiphop
Copy link
Contributor

LGTM - but I have one small request, could we add a system test that uses the raw option?

@stephenplusplus
Copy link
Contributor Author

Yeah, good call! Caught a 🐛

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling fcd1097 on stephenplusplus:spp--629 into fc7ebb8 on GoogleCloudPlatform:master.

@callmehiphop callmehiphop merged commit fecf108 into googleapis:master Oct 10, 2016
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.

4 participants