Skip to content

refactor: Improve var name. b/131773884#1262

Merged
grant merged 2 commits into
masterfrom
grant-131773884
May 6, 2019
Merged

refactor: Improve var name. b/131773884#1262
grant merged 2 commits into
masterfrom
grant-131773884

Conversation

@grant

@grant grant commented May 3, 2019

Copy link
Copy Markdown
Contributor

Improve var name.
See: b/131773884

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 3, 2019
@grant grant requested a review from ace-n May 3, 2019 17:16

@ace-n ace-n left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but want to run this past @stew-r as well.

@stew-r

stew-r commented May 3, 2019

Copy link
Copy Markdown
Contributor

Urgh. While I really want to do this I think we would cause more confusion than we would be solving. Today, IIRC, that object is not == PubsubMessage. It's only the data field from that object.

EDIT: scratch that. Need to do some additional investigation.

@grant

grant commented May 4, 2019

Copy link
Copy Markdown
Contributor Author

Urgh. While I really want to do this I think we would cause more confusion than we would be solving. Today, IIRC, that object is not == PubsubMessage. It's only the data field from that object.

EDIT: scratch that. Need to do some additional investigation.

Are you suggesting that the data field in the PubsubMessage has a nested data field as in data.data?

This PR has no functional changes, just inlining a variable.

@stew-r

stew-r commented May 6, 2019

Copy link
Copy Markdown
Contributor

I'm saying that if you write a function (subscribed to a Pub/Sub topic) like the following:

exports.helloPubSub = async (pubsubMessage, context) => {
  console.log(pubsubMessage);
}

And then publish a message to this Pub/Sub topic, you will get the following output:

{ 
  '@type': 'type.googleapis.com/google.pubsub.v1.PubsubMessage',
  attributes: { test_key: 'test_value' },
  data: 'dGVzdF9tZXNzYWdl' 
}

That's almost, but not quite, the same as PubsubMessage:

{
  "data": string,
  "attributes": {
    string: string,
    ...
  },
  "messageId": string,
  "publishTime": string
}

This is a point of confusion for users. We can talk about why this is the case and whether it should be changed.

@ace-n

ace-n commented May 6, 2019 via email

Copy link
Copy Markdown
Contributor

@grant

grant commented May 6, 2019

Copy link
Copy Markdown
Contributor Author

This change doesn't introduce functional changes. It simply removes an extra const from the sample as suggested in the bug report i.e. read something less confusing.

It does not attempt to edit the parameter type or solve the confusion Stewart mentioned.

@ace-n

ace-n commented May 6, 2019

Copy link
Copy Markdown
Contributor

Is there a reason we shouldn't resolve that confusion in this PR, if something like pubsubSnippet would do the trick?

@stew-r

stew-r commented May 6, 2019 via email

Copy link
Copy Markdown
Contributor

@grant

grant commented May 6, 2019

Copy link
Copy Markdown
Contributor Author

As discussed via Hangouts with Stewart, pubsubData or pubsubEvent are both fine. Changed the PR to reflect that.
PTAL.

@ace-n

ace-n commented May 6, 2019

Copy link
Copy Markdown
Contributor

LGTM. Thanks for following up @grant!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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