Skip to content

Conversation

@coryan
Copy link
Contributor

@coryan coryan commented Jul 6, 2018

This fixes #66. Until now, if you wanted to change one of the
policies in a Table, TableAdmin, or InstanceAdmin object you had
to pass all of them in the constructor. With this change you can
just pass the ones that you want to override. That makes life
easier for our users.

This fixes googleapis#66. Until now, if you wanted to change one of the
policies in a Table, TableAdmin, or InstanceAdmin object you had
to pass *all* of them in the constructor. With this change you can
just pass the ones that you want to override. That makes life
easier for our users.
@coryan coryan added the api: bigtable Issues related to the Bigtable API. label Jul 6, 2018
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 6, 2018
@coryan
Copy link
Contributor Author

coryan commented Jul 6, 2018

@saeta FYI. Let me know if this will not solve your problem with setting just one policy.

@codecov
Copy link

codecov bot commented Jul 6, 2018

Codecov Report

Merging #809 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #809      +/-   ##
==========================================
+ Coverage   95.58%   95.58%   +<.01%     
==========================================
  Files         144      144              
  Lines        3805     3808       +3     
==========================================
+ Hits         3637     3640       +3     
  Misses        168      168
Impacted Files Coverage Δ
google/cloud/bigtable/internal/table_admin.h 100% <ø> (ø) ⬆️
google/cloud/bigtable/internal/instance_admin.h 80.76% <ø> (ø) ⬆️
google/cloud/bigtable/table_admin.h 100% <ø> (ø) ⬆️
google/cloud/bigtable/table.h 100% <ø> (ø) ⬆️
google/cloud/bigtable/instance_admin.h 100% <100%> (ø) ⬆️
google/cloud/bigtable/internal/table.h 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 f6fa75d...893b9b5. Read the comment docs.

* - `PollingPolicy` for how long will the class wait for
* `google.longrunning.Operation` to complete. This class combines both
* the backoff policy for checking long running operations and the
* retry policy
Copy link
Contributor

Choose a reason for hiding this comment

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

End the sentence with a period? Others (above) do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

* - `PollingPolicy` for how long will the class wait for
* `google.longrunning.Operation` to complete. This class combines both
* the backoff policy for checking long running operations and the
* retry policy
Copy link
Contributor

Choose a reason for hiding this comment

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

End the sentence with a period? Others (above) do.

looks like this is copied from another file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Yes, it is a copy, I could just reference the documentation in bigtable::InstanceAdmin if you prefer.

Copy link
Contributor

Choose a reason for hiding this comment

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

It probably makes sense to keep it where it is so the docs are anywhere someone might see them, so no need to cross-reference, let's keep it as-is.

}

template <typename Policy, typename... Policies>
void ChangePolicies(Policy&& policy, Policies&&... policies) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, I like the functional-style list processing using C++ templates here, I guess this is where && is really useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, perfect forwarding FTW.

* - `PollingPolicy` for how long will the class wait for
* `google.longrunning.Operation` to complete. This class combines both
* the backoff policy for checking long running operations and the
* retry policy
Copy link
Contributor

Choose a reason for hiding this comment

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

End the sentence with a period? Others (above) do.

looks like this is copied from another file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

TEST_F(NoexTableTest, ChangeOnePolicy) {
bigtable::noex::Table table(client_, "some-table",
bigtable::AlwaysRetryMutationPolicy());
EXPECT_THAT(table.table_name(), ::testing::HasSubstr("some-table"));
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't really test anything about the policy except that it compiles, right? Should this do a retry on a few (mock) errors to demonstrate the retry policy, or is that overkill?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, there other test that actually use the policy, for example:

https://github.com/GoogleCloudPlatform/google-cloud-cpp/blob/f6fa75d463c522072f46e5ef3cfe5918efc31fdd/google/cloud/bigtable/table_bulk_apply_test.cc#L187

I could create an accessor to read the policy back and figure out if it is of the desired type, but that feels icky. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

No worries, as long as there's an existing test for this, SGTM.

bigtable::noex::Table table(client_, "some-table",
bigtable::AlwaysRetryMutationPolicy(),
bigtable::LimitedErrorCountRetryPolicy(42));
EXPECT_THAT(table.table_name(), ::testing::HasSubstr("some-table"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly here: this is not testing either the always-retry-until-N-errors policy. Should that be done here, or is that out of scope?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See above.

* - `PollingPolicy` for how long will the class wait for
* `google.longrunning.Operation` to complete. This class combines both
* the backoff policy for checking long running operations and the
* retry policy
Copy link
Contributor

Choose a reason for hiding this comment

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

End the sentence with a period? Others (above) do.

looks like this is copied from another file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Sorry for the comment duplication. This is the only way to make them appear in all the right places for Doxygen.

Copy link
Contributor

@mbrukman mbrukman left a comment

Choose a reason for hiding this comment

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

LGTM

@coryan coryan merged commit f875700 into googleapis:master Jul 6, 2018
@coryan coryan deleted the override-only-some-policies branch July 6, 2018 21:05
@saeta
Copy link
Contributor

saeta commented Jul 6, 2018

This looks great. Thank you!

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

Labels

api: bigtable Issues related to the Bigtable API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider making some policies optional in Table constructor.

4 participants