damccorm commented on code in PR #39004:
URL: https://github.com/apache/beam/pull/39004#discussion_r3506905349
##########
sdks/java/ml/inference/remote/src/main/java/org/apache/beam/sdk/ml/inference/remote/RetryHandler.java:
##########
@@ -34,24 +34,42 @@ public class RetryHandler implements Serializable {
private final Duration initialBackoff;
private final Duration maxBackoff;
private final Duration maxCumulativeBackoff;
+ private final RetryFilter retryFilter;
+
+ @FunctionalInterface
+ public interface RetryFilter extends Serializable {
+ boolean shouldRetry(Exception e);
+ }
private RetryHandler(
- int maxRetries, Duration initialBackoff, Duration maxBackoff, Duration
maxCumulativeBackoff) {
+ int maxRetries,
+ Duration initialBackoff,
+ Duration maxBackoff,
+ Duration maxCumulativeBackoff,
+ RetryFilter retryFilter) {
this.maxRetries = maxRetries;
this.initialBackoff = initialBackoff;
this.maxBackoff = maxBackoff;
this.maxCumulativeBackoff = maxCumulativeBackoff;
+ this.retryFilter =
+ java.util.Objects.requireNonNull(retryFilter, "retryFilter must not be
null");
}
public static RetryHandler withDefaults() {
return new RetryHandler(
3, // maxRetries
Duration.standardSeconds(1), // initialBackoff
Duration.standardSeconds(10), // maxBackoff per retry
- Duration.standardMinutes(1) // maxCumulativeBackoff
+ Duration.standardMinutes(1), // maxCumulativeBackoff
+ e -> true // retryFilter default to retrying all exceptions
);
}
+ public RetryHandler withRetryFilter(RetryFilter retryFilter) {
Review Comment:
Do we have any OOB model handlers, and if so should we be setting this for
them? If not, it would be good to at least have a Gemini one as an example/use
case
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]