Skip to content

feat(common): add custom predicate matching to RetryPolicy#59

Merged
viacheslav-rostovtsev merged 3 commits into
googleapis:mainfrom
viacheslav-rostovtsev:dev/virost/feat/retry-errortypes
Jul 6, 2026
Merged

feat(common): add custom predicate matching to RetryPolicy#59
viacheslav-rostovtsev merged 3 commits into
googleapis:mainfrom
viacheslav-rostovtsev:dev/virost/feat/retry-errortypes

Conversation

@viacheslav-rostovtsev

Copy link
Copy Markdown
Member

feat(common): add custom predicate matching to RetryPolicy

For Scotty we'll need to retry on non-HTTP/GRPC errors, e.g. on low-level socket timeout error. This seemed generic enough (and present in other languages e.g. python) to add to a RetryPolicy.

Adds a retry_predicate: keyword argument to Gapic::Common::RetryPolicy to support matching retry errors against a custom callable predicate.

Behavior

When a predicate is specified:

  1. The predicate is executed first on the error.
  2. If it returns nil, the decision on whether to retry is made on the basis of retry_codes.
  3. Otherwise, the truthiness of the return value determines whether to retry.

Intentional Scope

Support for retry_predicate: was intentionally omitted from Gapic::CallOptions::RetryPolicy and Gapic::Operation::RetryPolicy.
We can add it there if needed. Scotty code will use the Gapic::Common::RetryPolicy code.

@viacheslav-rostovtsev viacheslav-rostovtsev requested a review from a team as a code owner June 23, 2026 19:41
Comment thread gapic-common/lib/gapic/common/retry_policy.rb
Comment thread gapic-common/lib/gapic/common/retry_policy.rb
@quartzmo quartzmo closed this Jun 24, 2026
@quartzmo quartzmo reopened this Jun 24, 2026
@quartzmo quartzmo closed this Jun 25, 2026
@quartzmo quartzmo reopened this Jun 25, 2026
@quartzmo quartzmo closed this Jun 25, 2026
@quartzmo quartzmo reopened this Jun 25, 2026
@quartzmo quartzmo force-pushed the dev/virost/feat/retry-errortypes branch from f09a863 to ce54b74 Compare June 25, 2026 22:42
Comment thread gapic-common/lib/gapic/common/retry_policy.rb
@viacheslav-rostovtsev viacheslav-rostovtsev force-pushed the dev/virost/feat/retry-errortypes branch from f1dadfd to c3732f9 Compare July 6, 2026 22:59
@viacheslav-rostovtsev viacheslav-rostovtsev merged commit b591048 into googleapis:main Jul 6, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants