Git Product home page Git Product logo

Comments (3)

marcomorain avatar marcomorain commented on September 26, 2024

I think you need to invert what you consider success and failure.

You could do this by throwing an IoException when your job is successfull,
and when your job fails, catch all exceptions and return a normal result.

If you make your job be Callable, and catch any exceptions that
fire in the run method and return them.

If no exceptions are thrown then throw a new IoException.

:)

On Monday, 12 May 2014, parxier [email protected] wrote:

I have a use case where I need to retry few times even on successful
result and fail immediately if there were any failures in between.

For instance my callable returns an Integer, I'd like to retry 5 times
even when callable returns expected Integer, but fail immediately when it
returns unexpected result.

I couldn't find an easy way to do this with current API.


Reply to this email directly or view it on GitHubhttps://github.com//issues/22
.

from guava-retrying.

parxier avatar parxier commented on September 26, 2024

@marcomorain thanks for a suggestion, but no matter how hard I tried I couldn't get it working the way you describe.

What I did instead is I left callable as is, but reversed result predicate, so instead of using retryIfResult(not(equalTo(expected))) I use retryIfResult(equalTo(expected)). This causes retry on success. Then if retryer.call(operation) returns successfully it means there was an error. Also if it throws RetryException I catch it and do nothing as it means that all attempts were successful.

It is cumbersome, but works with current retryer API.

from guava-retrying.

rholder avatar rholder commented on September 26, 2024

This appears to be resolved.

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.