r/java • u/jodah1 • Jun 12 '16
Failsafe - A lightweight, zero-dependency library for handling failures
https://github.com/jhalterman/failsafe3
Jun 12 '16
How does this compare to guava retriable? It looks great, just curious if it does things nicer or different
5
u/jodah1 Jun 13 '16 edited Jun 13 '16
This library? https://github.com/rholder/guava-retrying
The basic retry functionality is similar, but they differ in numerous other ways. Compared to guava-retrying, Failsafe:
Doesn't require Guava (which is nice for people/projects that don't use Guava)
Supports async retries
Integrates nicely with Java 8 and CompletableFutures
Integrates with 3rd party asynchronous APIs (like Vertx, RxJava, etc.)
Supports standalone retry/execution tracking
Supports event listeners
Provides a pretty nice circuit breaker implementation
...and wraps it all in a fairly tidy API.
3
Jun 12 '16
Looks good. Reminds me a lot of AsyncRetry https://github.com/nurkiewicz/async-retry
3
u/jodah1 Jun 13 '16 edited Jun 13 '16
I was aware of AsyncRetry, and the retry capabilities are similar, but one of the main motivations for Failsafe was support for Java 6+ (AsyncRetry is only Java 8, or Java 7 with Guava) and no external dependencies while still providing really good Java 8 integration. Another primary motivation was to create something with as clean/concise of an API as possible (which I hope was achieved). A few other differences and motivation:
Event listeners
Asynchronous API integration and support for 3rd party schedulers
Standalone retry/execution tracking
Circuit breakers
Overall, Failsafe is intended to provide different strategies for dealing with failures. Retries and circuit breakers are supported initially, but there may be more to come in future releases.
1
1
u/mrbonner Jun 16 '16
How bulkhead work without a separate thread pool? I know hytrix has it thought out very well. Nice code though!
1
u/jodah1 Jun 16 '16
Failsafe doesn't have a bulkhead implementation. For asynchronous executions, users supply the threadpool / scheduler that they want to use, rather than having it managed internally such as with Hystrix.
3
-1
u/iperc Jun 13 '16
This is a cool idea. But i don't want to include vertext and netty dependencies because i don't user them. Would be great if i can include them on demand. Sorry for by bad English.
2
u/jodah1 Jun 13 '16 edited Jun 13 '16
I can understand the mistake. Just added comments to the pom mentioning they're just test/examples dependencies so it stands out a bit more.
4
0
Jun 13 '16
[deleted]
1
u/jodah1 Jun 13 '16 edited Jun 13 '16
Possibly, though technology name recognition tends to be contextual - Failsafe and Maven Failsafe are very different technologies. We usually say "Maven Failsafe Plugin" or "Maven Failsafe", so hopefully when someone just says "Failsafe" we'll know they don't mean the Maven plugin thing.
Failsafe is really a perfect name for this library, so we felt it was worth using even despite the possibility for occasional confusion.
2
1
u/spencer205 Jun 14 '16
I agree the name may not be ideal, though the library and it's docs look killer! Failsafe means the maven plugin where I work. Also, see that little TM on Apache's site? Not sure of that could be an issue for this project or not. (Hope not)
1
1
Jun 13 '16
[removed] — view removed comment
1
u/jodah1 Jun 13 '16 edited Jun 13 '16
Sure, adapted from the README on github:
Failsafe is a library for handling failures with a concise API and a flexible feature set. Failure handling strategies include configurable synchronous and asynchronous retries, circuit breakers, and various other features to help integrate into any type of failure handling use case.
33
u/Sqirril Jun 12 '16 edited Jul 14 '23
..........................