-
Notifications
You must be signed in to change notification settings - Fork 2
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
CDF-20260: allow customizing shouldRetry in RetryingBackend #708
Conversation
Predicate takes `request` and `response code` and it can be used in consuming projects by tagging request with extra settings if needed and applying custom policy. Default policy is also exposed for reuse. There's already `GenericClient.RESOURCE_TYPE_TAG` applied by default on sdk side, so customization by resource type + response code should be fairly easy to implement. Not giving it full response (and response headers) for now because in current setup response can be shadowed by exceptions that don't keep track of full response context. Later on if the need for response header-based logic arises we could extend this part in some way. TBD: it may make sense that customization for resource + code is put in the sdk default policy if that will be a fairly certain rule. But first let's open up for customizations
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #708 +/- ##
==========================================
+ Coverage 73.95% 73.97% +0.01%
==========================================
Files 95 95
Lines 2880 2882 +2
Branches 33 36 +3
==========================================
+ Hits 2130 2132 +2
Misses 750 750
|
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.
LGTM, modulo me not knowing what I'm talking about
val maybeRetry: (Option[Int], Throwable) => F[Response[T]] = | ||
(code: Option[Int], exception: Throwable) => | ||
if (retriesRemaining > 0 && code.forall(shouldRetry)) { | ||
val maybeRetry: (Option[StatusCode], Throwable) => F[Response[T]] = |
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.
💯 proper types are key to making lambda function signatures readable.
Uh I didn't realize my +1 would cause an automerge 😅 |
Predicate takes
request
andresponse code
and it canbe used in consuming projects by tagging request with extra settings
if needed and applying custom policy. Default policy is also exposed
for reuse.
There's already
GenericClient.RESOURCE_TYPE_TAG
applied by default onsdk side, so customization by resource type + response code should be
fairly easy to implement.
Not giving it full response (and response headers) for now because
in current setup response can be shadowed by exceptions that don't
keep track of full response context. Later on if the need for response
header-based logic arises we could extend this part in some way.
TBD: it may make sense that customization for resource + code
is put in the sdk default policy if that will be a fairly certain rule.
But first let's open up for customizations
Relates to #706
Needed for #709
CDF-20260