-
Notifications
You must be signed in to change notification settings - Fork 455
feat(bigtable): Add support for adding tags to an Instance in InstanceConfig #16014
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,6 +67,22 @@ class InstanceConfig { | |
| return *this; | ||
| } | ||
|
|
||
| InstanceConfig& insert_tag(std::string const& key, std::string const& value) { | ||
| (*proto_.mutable_instance()->mutable_tags())[key] = value; | ||
| return *this; | ||
| } | ||
|
|
||
| InstanceConfig& emplace_tag(std::string const& key, std::string value) { | ||
| (*proto_.mutable_instance()->mutable_tags())[key] = std::move(value); | ||
| return *this; | ||
| } | ||
|
|
||
| InstanceConfig& emplace_tag(std::string&& key, std::string value) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need this overload? I know this is probably added because of the code assist, but looking at insert_label and emplace_label, it only has
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's fine to leave it. The *_label functions could be similarly improved. |
||
| (*proto_.mutable_instance()->mutable_tags())[std::move(key)] = | ||
| std::move(value); | ||
| return *this; | ||
| } | ||
|
|
||
| // NOLINT: accessors can (and should) be snake_case. | ||
| google::bigtable::admin::v2::CreateInstanceRequest const& as_proto() const& { | ||
| return proto_; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To optimize for cases where the key is an rvalue (e.g., a temporary from a string literal), consider adding an overload for
emplace_tagthat accepts an rvalue reference for thekey. This allows moving the key into the map instead of copying it, improving efficiency.A similar improvement could be made to
emplace_labelin a follow-up change for consistency.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done