All Projects → rhuffman → re-retrying

rhuffman / re-retrying

Licence: Apache-2.0 License
A Java library to allow for the creation of configurable retrying strategies for an arbitrary function call, such as something that communicates with a remote service with flaky uptime.

Programming Languages

java
68154 projects - #9 most used programming language

Labels

Projects that are alternatives of or similar to re-retrying

Resilient.js
Fault tolerant and reactive HTTP client for node.js and browsers
Stars: ✭ 172 (+377.78%)
Mutual labels:  retry
View-Load-ReTry
这个加载框架有点不一样,针对View进行加载,加载页面还保持了原View的属性,侧重点在灵活,哪里需要加载哪里,加载状态页面完全自定义,无任何限制,针对加载结果可以按需配置对应页面,LeakCanary检测无内存泄漏
Stars: ✭ 116 (+222.22%)
Mutual labels:  retry
retrygroup
Package retrygroup provides synchronization, Context cancelation for groups of retry goroutines working on subtasks of a common task.
Stars: ✭ 18 (-50%)
Mutual labels:  retry
Retry4j
Lightweight Java library for retrying unreliable logic
Stars: ✭ 179 (+397.22%)
Mutual labels:  retry
esa-httpclient
An asynchronous event-driven HTTP client based on netty.
Stars: ✭ 82 (+127.78%)
Mutual labels:  retry
jest-retry
Jest retry pattern for flaky E2E tests
Stars: ✭ 36 (+0%)
Mutual labels:  retry
Kotlin Retry
A higher-order function for retrying operations that may fail.
Stars: ✭ 159 (+341.67%)
Mutual labels:  retry
backoff
PHP library providing retry functionality with multiple backoff strategies and jitter support
Stars: ✭ 132 (+266.67%)
Mutual labels:  retry
retries
Forget about your retry boilerplate
Stars: ✭ 14 (-61.11%)
Mutual labels:  retry
java-sdk
一些常用的java sdk和工具类(日期工具类,分布式锁,redis缓存,二叉树,反射工具类,线程池,对称/非对称/分段加解密,json序列化,http工具,雪花算法,字符串相似度,集合操作工具,xml解析,重试Retry工具类,Jvm监控等)
Stars: ✭ 26 (-27.78%)
Mutual labels:  retry
Afnetworking Retrypolicy
Nice category that adds the ability to set the retry interval, retry count and progressiveness.
Stars: ✭ 197 (+447.22%)
Mutual labels:  retry
Toxy
Hackable HTTP proxy for resiliency testing and simulated network conditions
Stars: ✭ 2,698 (+7394.44%)
Mutual labels:  retry
php-backoff
Simple back off / retry functionality
Stars: ✭ 24 (-33.33%)
Mutual labels:  retry
Loadmorewrapper
📦 make recyclerView supports load more and customize the footer view, without changes to the original adater of recyclerView. 在不改动 RecyclerView 原有的 adapter 的情况下,使 RecyclerView 滑动到底部的时候能够加载更多和自定义底部视图。
Stars: ✭ 179 (+397.22%)
Mutual labels:  retry
retryx
Promise-based retry workflow library.
Stars: ✭ 21 (-41.67%)
Mutual labels:  retry
Rehttp
Package rehttp implements a Go HTTP transport that handles retries.
Stars: ✭ 170 (+372.22%)
Mutual labels:  retry
request-on-steroids
An HTTP client ✨ with retry, circuit-breaker and tor support 📦 out-of-the-box
Stars: ✭ 19 (-47.22%)
Mutual labels:  retry
retry
Simple and easy retry mechanism package for Go
Stars: ✭ 54 (+50%)
Mutual labels:  retry
HTMLTestRunner cn
HTMLTestRunner 汉化版,同时支持python 2和3,增加截图展示功能,失败重试
Stars: ✭ 191 (+430.56%)
Mutual labels:  retry
typescript-retry-decorator
lightweight typescript retry decorator with 0 dependency.
Stars: ✭ 50 (+38.89%)
Mutual labels:  retry

Build Status Latest Version License

What is this?

The re-retrying module provides a general purpose method for retrying arbitrary Java code with specific stop, retry, and exception handling capabilities that are enhanced by Guava's predicate matching.

This is a fork of the guava-retrying library by Ryan Holder (rholder), which is itself a fork of the RetryerBuilder by Jean-Baptiste Nizet (JB). The guava-retrying project added a Gradle build for pushing it up to Maven Central, and exponential and Fibonacci backoff WaitStrategies that might be useful for situations where more well-behaved service polling is preferred.

Why was this fork necessary? The primary reason was to make it compatible with projects using later versions of Guava. See this project's Wiki for more details.

Maven

    <dependency>
      <groupId>tech.huffman.re-retrying</groupId>
      <artifactId>re-retrying</artifactId>
      <version>3.0.0</version>
    </dependency>

Gradle

    compile "tech.huffman.re-retrying:re-retrying:3.0.0"

Quickstart

Given a function that reads an integer:

public int readAnInteger() throws IOException {
   ...
}

The following will retry if the result of the method is zero, if an IOException is thrown, or if any other RuntimeException is thrown from the call() method. It will stop after attempting to retry 3 times and throw a RetryException that contains information about the last failed attempt. If any other Exception pops out of the call() method it's wrapped and rethrown in an ExecutionException.

    Retryer retryer = RetryerBuilder.newBuilder()
        .retryIfResult(Predicates.equalTo(0))
        .retryIfExceptionOfType(IOException.class)
        .retryIfRuntimeException()
        .withStopStrategy(StopStrategies.stopAfterAttempt(3))
        .build();
    try {
      retryer.call(this::readAnInteger);
    } catch (RetryException | ExecutionException e) {
      e.printStackTrace();
    }

Exponential Backoff

Create a Retryer that retries forever, waiting after every failed retry in increasing exponential backoff intervals until at most 5 minutes. After 5 minutes, retry from then on in 5 minute intervals.

Retryer retryer = RetryerBuilder.newBuilder()
        .retryIfExceptionOfType(IOException.class)
        .retryIfRuntimeException()
        .withWaitStrategy(WaitStrategies.exponentialWait(100, 5, TimeUnit.MINUTES))
        .withStopStrategy(StopStrategies.neverStop())
        .build();

You can read more about exponential backoff and the historic role it played in the development of TCP/IP in Congestion Avoidance and Control.

Fibonacci Backoff

Create a Retryer that retries forever, waiting after every failed retry in increasing Fibonacci backoff intervals until at most 2 minutes. After 2 minutes, retry from then on in 2 minute intervals.

Retryer retryer = RetryerBuilder.newBuilder()
        .retryIfExceptionOfType(IOException.class)
        .retryIfRuntimeException()
        .withWaitStrategy(WaitStrategies.fibonacciWait(100, 2, TimeUnit.MINUTES))
        .withStopStrategy(StopStrategies.neverStop())
        .build();

Similar to the ExponentialWaitStrategy, the FibonacciWaitStrategy follows a pattern of waiting an increasing amount of time after each failed attempt.

Instead of an exponential function it's (obviously) using a Fibonacci sequence to calculate the wait time.

Depending on the problem at hand, the FibonacciWaitStrategy might perform better and lead to better throughput than the ExponentialWaitStrategy - at least according to A Performance Comparison of Different Backoff Algorithms under Different Rebroadcast Probabilities for MANETs.

The implementation of FibonacciWaitStrategy is using an iterative version of the Fibonacci because a (naive) recursive version will lead to a StackOverflowError at a certain point (although very unlikely with useful parameters for retrying).

Inspiration for this implementation came from Efficient retry/backoff mechanisms.

Documentation

Javadoc can be found here.

Building from source

The re-retrying module uses a Gradle-based build system. In the instructions below, ./gradlew is invoked from the root of the source tree and serves as a cross-platform, self-contained bootstrap mechanism for the build. The only prerequisites are Git and JDK 1.8+.

check out sources

git clone git://github.com/rhuffman/re-retrying.git

compile and test, build all jars

./gradlew build

install all jars into your local Maven cache

./gradlew install

License

The re-retrying module is released under version 2.0 of the Apache License.

Contributors

  • Jean-Baptiste Nizet (JB)
  • Jason Dunkelberger (dirkraft)
  • Diwaker Gupta (diwakergupta)
  • Jochen Schalanda (joschi)
  • Shajahan Palayil (shasts)
  • Olivier Grégoire (fror)
  • Andrei Savu (andreisavu)
  • (tchdp)
  • (squalloser)
  • Yaroslav Matveychuk (yaroslavm)
  • Stephan Schroevers (Stephan202)
  • Chad (voiceinsideyou)
  • Kevin Conaway (kevinconaway)
  • Alberto Scotto (alb-i986)
  • Ryan Holder(rholder)
  • Robert Huffman (rhuffman)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].