Skip to content

Fallback doesn't support .handleResult #55

Description

@alexandergunnarson

I'd like to throw an exception when retries are exceeded. Per https://failsafe.dev/faqs/#how-to-i-throw-an-exception-when-retries-are-exceeded, here's what they recommend (and what works on my machine):

// Retry on a null result
RetryPolicy<Connection> retryPolicy = RetryPolicy.<Connection>builder()
  .handleResult(null)
  .build();
  
// Fallback on a null result with a ConnectException
Fallback<Connection> fallback = Fallback.<Connection>builderOfException(e -> {
    return new ConnectException("Connection failed after retries");
  })
  .handleResult(null)
  .build();

Failsafe.with(fallback).compose(retryPolicy).get(this::getConnection);

This means diehard.core/fallback would have to be reworked slightly to support .handleResult etc.

Awesome library by the way! 🙌 Great functionality, and great abstraction over the Java lib.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions