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

We should release our policy types #9434

Closed
dbolduc opened this issue Jul 6, 2022 · 3 comments · Fixed by #12040
Closed

We should release our policy types #9434

dbolduc opened this issue Jul 6, 2022 · 3 comments · Fixed by #12040
Assignees
Labels
type: cleanup An internal cleanup or hygiene concern.

Comments

@dbolduc
Copy link
Member

dbolduc commented Jul 6, 2022

We define policy types like this:

using AccessApprovalRetryPolicy =
::google::cloud::internal::TraitBasedRetryPolicy<
accessapproval_internal::AccessApprovalRetryTraits>;

This is in violation of https://github.com/googleapis/google-cloud-cpp/blob/main/doc/adr/2022-01-21-only-public-types-in-public-APIs.md

There is no way to learn the interface of this type, other than by looking at the code. (Doxygen does not generate documentation for internal::TraitBasedRetryPolicy<T>)

To allow for customer-defined retry policies, I think we need to release RetryPolicy and TraitBasedRetryPolicy.

@dbolduc dbolduc added the type: cleanup An internal cleanup or hygiene concern. label Jul 6, 2022
@coryan
Copy link
Contributor

coryan commented Dec 21, 2022

Consider this for 2023/Q1.

@coryan
Copy link
Contributor

coryan commented Apr 26, 2023

One alternative is to just generate:

class AccessApprovalRetryPolicy : public google::internal::.... {
 public:
  /// Pretty explanations for Doxygen and friends.
  bool OnFailure(Status const& ...) override { return Base::OnFailure(...); }

};

and then manually do the same for the hand-crafted libraries.

We probably need to write a one pager.

@coryan
Copy link
Contributor

coryan commented Jun 30, 2023

We decided to implement something along these lines:

struct EkmServiceRetryPolicy : public google::cloud::RetryPolicy {
 public:
   /// Documented expectations for this function go here
   virtual std::unique_ptr<EkmServiceRetryPolicy> clone() const = 0;
};

class EkmServiceLimitedTimeRetryPolicy : public EkmServiceRetryPolicy {
 public:
  explicit LimitedErrorCountRetryPolicy(int maximum_failures)
      : impl_(maximum_failures) {}

  std::unique_ptr<EkmServiceRetryPolicy> clone() const override {
    return std::make_unique<EkmServiceLimitedTimeRetryPolicy>(impl_.maximum_failures());
  }
  bool OnFailure(Status const& s) override { return impl_.OnFailure(s); }
  bool IsExhausted() const override { return impl_.IsExhausted(); }
  bool IsPermanentFailure(Status const& s) const override {
    return impl_.IsPermanentFailure(s);
  } 
 private:
   google::cloud::internal::LimitedTimeRetryPolicy<
        kms_v1_internal::EkmServiceRetryTraits> impl_;
};

class EkmServiceLimitedErrorCountRetryPolicy : public EkmServiceRetryPolicy {
// Same idea as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: cleanup An internal cleanup or hygiene concern.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants