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

refactor: Improve var name. b/131773884 #1262

Merged
merged 2 commits into from
May 6, 2019
Merged

refactor: Improve var name. b/131773884 #1262

merged 2 commits into from
May 6, 2019

Conversation

grant
Copy link
Contributor

@grant grant commented May 3, 2019

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
Copy link
Contributor

@ace-n ace-n left a comment

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
Copy link
Contributor

stew-r commented May 3, 2019

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
Copy link
Contributor Author

grant commented May 4, 2019

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
Copy link
Contributor

stew-r commented May 6, 2019

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
Copy link
Contributor

ace-n commented May 6, 2019 via email

@grant
Copy link
Contributor Author

grant commented May 6, 2019

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
Copy link
Contributor

ace-n commented May 6, 2019

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

@stew-r
Copy link
Contributor

stew-r commented May 6, 2019 via email

@grant
Copy link
Contributor Author

grant commented May 6, 2019

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

@ace-n
Copy link
Contributor

ace-n commented May 6, 2019

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