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

feat(topic): create setMetadata method #537

Merged
merged 1 commit into from
Mar 9, 2019
Merged

feat(topic): create setMetadata method #537

merged 1 commit into from
Mar 9, 2019

Conversation

callmehiphop
Copy link
Contributor

@callmehiphop callmehiphop commented Mar 8, 2019

Relates to #496

  • Tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 8, 2019
@codecov
Copy link

codecov bot commented Mar 8, 2019

Codecov Report

Merging #537 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #537      +/-   ##
==========================================
+ Coverage   94.78%   94.81%   +0.03%     
==========================================
  Files          16       16              
  Lines         959      965       +6     
  Branches       84       86       +2     
==========================================
+ Hits          909      915       +6     
  Misses         42       42              
  Partials        8        8
Impacted Files Coverage Δ
src/topic.ts 90.66% <100%> (+0.81%) ⬆️
src/index.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd727e1...209da9a. Read the comment docs.

type MetadataCallback = RequestCallback<TopicMetadata>;
type MetadataResponse = [TopicMetadata];

export type GetTopicMetadataCallback = MetadataCallback;
Copy link
Contributor

Choose a reason for hiding this comment

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

So - why not just use MetadataCallback over creating all of these specialized interfaces?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At this point it would be another breaking change, I thought maybe I'd give ya'll a break from those :p

Copy link
Contributor

@bcoe bcoe left a comment

Choose a reason for hiding this comment

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

It's my first week so please put up with me 😆

If I'm reading #496 correctly, the issue is that testing environments are populating the labels field on a topic, and you want to use the method setMetadata to pass {labels: {}} and zero out this value? this seems reasonable to me.

I'm wondering if it might be wroth calling the method updateTopic, so that it better matches the naming conventions of the docs; especially since, if I'm reading correctly, this method could also be used to change the topic name?

@@ -440,7 +448,7 @@ export class Topic {
topic: this.name,
};

this.request<google.pubsub.v1.ITopic>(
Copy link
Contributor

Choose a reason for hiding this comment

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

I like that google.pubsub.v1.ITopic has been abstracted into a variable earlier in the file, reads better.

/**
* Updates the topic.
*
* @see [UpdateTopicRequest API Documentation]{@link https://cloud.google.com/pubsub/docs/reference/rest/v1/UpdateTopicRequest}
Copy link
Contributor

Choose a reason for hiding this comment

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

from reading this documentation, am I reading correctly that labels are the only "meta information" you would potentially change on a topic, and this method since it's calling updateTopic would also potentially be able to change the name of a topic?

I wonder if a better method name would just be updateTopic? which would better match the upstream API too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

setMetadata is the generic method name we use across all the libraries to update resource fields. I'm definitely not married to it or anything, just went with it for the sake of consistency. I'd be ok with moving away from some of our older conventions to better mirror the upstream apis.

@JustinBeckwith @stephenplusplus @jkwlui what do you guys think?

@stephenplusplus
Copy link
Contributor

Why isn't Topic a ServiceObject?

@JustinBeckwith
Copy link
Contributor

So I had that question at first too. Then I noticed - this module doesn't use any of the common modules 😆

@callmehiphop
Copy link
Contributor Author

@stephenplusplus My memory is kind of fuzzy on this, but I think when we switched from the rest api to grpc the direction was to just use gax and skip all the common lib stuff.

Copy link
Contributor

@bcoe bcoe left a comment

Choose a reason for hiding this comment

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

works for me, if we use setMetadata consistently across other APIs, not grounds to block this 😄

@JustinBeckwith JustinBeckwith merged commit 20eb583 into googleapis:master Mar 9, 2019
feywind pushed a commit to feywind/nodejs-pubsub that referenced this pull request Nov 12, 2024
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.

5 participants