Git Product home page Git Product logo

Comments (1)

rholder avatar rholder commented on September 26, 2024

Currently, guava-retrying enables the customization of several distinct condition-checking interfaces for determining the retrying behavior: StopStrategy for explicit hard stop conditions, WaitStrategy for computing how long to wait between retry attempts, various Predicate evaluations on results and exceptions, and an integration with Guava's TimeLimiter. The included concrete implementations have been built around constructs that don't require global state or coordination among other bits of code in order to locally manage the retrying behavior for a single repeated function call.

A WaitStrategy is exposed as a nice little interface to create custom implementations of in your own applications that are built on top of this module. In order to keep this a very small interface footprint, I would not be excited to add chaining directly to the WaitStrategy in the RetryerBuilder, such as:

public static final Retryer<Object> COMPOSED_WAITS = RetryerBuilder.newBuilder()
        .withWaitStrategy(WaitStrategies.exponentialWait(100, 15, TimeUnit.SECONDS))
        .withWaitStrategy(WaitStrategies.fibonacciWait()
        .withStopStrategy(StopStrategies.stopAfterAttempt(10))
        .build();

I'm not sure that's exactly the route you had in mind, but just in case it was I wanted to save you some time. A more fun implementation might actually be a single join method in WaitStrategies where each strategy is combined together in such a way that they each add to the computed sleep value that is returned, such as:

public static WaitStrategy join(WaitStrategy... strategies)

In this way, we maintain the simplicity of the original interfacing while still adding the ability to express many more variants of WaitStrategy constructs. This is a very nice idea. Thanks for bringing it up and offering to help with it.

from guava-retrying.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.