Skip to content
This repository was archived by the owner on Mar 17, 2026. It is now read-only.

feat(topic): create setMetadata method#537

Merged
JustinBeckwith merged 1 commit into
googleapis:masterfrom
callmehiphop:dg--topic-set-metadata
Mar 9, 2019
Merged

feat(topic): create setMetadata method#537
JustinBeckwith merged 1 commit into
googleapis:masterfrom
callmehiphop:dg--topic-set-metadata

Conversation

@callmehiphop

@callmehiphop callmehiphop commented Mar 8, 2019

Copy link
Copy Markdown
Contributor

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

codecov Bot commented Mar 8, 2019

Copy link
Copy Markdown

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.

Comment thread src/topic.ts
type MetadataCallback = RequestCallback<TopicMetadata>;
type MetadataResponse = [TopicMetadata];

export type GetTopicMetadataCallback = MetadataCallback;

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.

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

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

@bcoe bcoe left a comment

Copy link
Copy Markdown

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?

Comment thread src/topic.ts
topic: this.name,
};

this.request<google.pubsub.v1.ITopic>(

Copy link
Copy Markdown

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.

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

Copy link
Copy Markdown

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

Why isn't Topic a ServiceObject?

@JustinBeckwith

Copy link
Copy Markdown
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
Copy Markdown
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.

@bcoe bcoe left a comment

Copy link
Copy Markdown

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

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