All Projects → lowzj → java-retrying

lowzj / java-retrying

Licence: Apache-2.0 License
java retry module, based on guava-retrying, support sync/async retry

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to java-retrying

sisyphus
The java retry framework.(支持注解的 java 重试框架)
Stars: ✭ 126 (+563.16%)
Mutual labels:  retry, java-retry
re-retrying
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.
Stars: ✭ 36 (+89.47%)
Mutual labels:  retry
Toxy
Hackable HTTP proxy for resiliency testing and simulated network conditions
Stars: ✭ 2,698 (+14100%)
Mutual labels:  retry
java-sdk
一些常用的java sdk和工具类(日期工具类,分布式锁,redis缓存,二叉树,反射工具类,线程池,对称/非对称/分段加解密,json序列化,http工具,雪花算法,字符串相似度,集合操作工具,xml解析,重试Retry工具类,Jvm监控等)
Stars: ✭ 26 (+36.84%)
Mutual labels:  retry
retries
Forget about your retry boilerplate
Stars: ✭ 14 (-26.32%)
Mutual labels:  retry
retryx
Promise-based retry workflow library.
Stars: ✭ 21 (+10.53%)
Mutual labels:  retry
Afnetworking Retrypolicy
Nice category that adds the ability to set the retry interval, retry count and progressiveness.
Stars: ✭ 197 (+936.84%)
Mutual labels:  retry
php-backoff
Simple back off / retry functionality
Stars: ✭ 24 (+26.32%)
Mutual labels:  retry
typescript-retry-decorator
lightweight typescript retry decorator with 0 dependency.
Stars: ✭ 50 (+163.16%)
Mutual labels:  retry
retry
Simple and easy retry mechanism package for Go
Stars: ✭ 54 (+184.21%)
Mutual labels:  retry
View-Load-ReTry
这个加载框架有点不一样,针对View进行加载,加载页面还保持了原View的属性,侧重点在灵活,哪里需要加载哪里,加载状态页面完全自定义,无任何限制,针对加载结果可以按需配置对应页面,LeakCanary检测无内存泄漏
Stars: ✭ 116 (+510.53%)
Mutual labels:  retry
jest-retry
Jest retry pattern for flaky E2E tests
Stars: ✭ 36 (+89.47%)
Mutual labels:  retry
HTMLTestRunner cn
HTMLTestRunner 汉化版,同时支持python 2和3,增加截图展示功能,失败重试
Stars: ✭ 191 (+905.26%)
Mutual labels:  retry
esa-httpclient
An asynchronous event-driven HTTP client based on netty.
Stars: ✭ 82 (+331.58%)
Mutual labels:  retry
resilience4clj-circuitbreaker
Resilience4Clj circuit breaker lets you decorate a function call (usually with a potential of external failure) with a safety mechanism to interrupt the propagation of failures.
Stars: ✭ 40 (+110.53%)
Mutual labels:  retry
Mug
A small Java 8 util library, complementary to Guava (BiStream, Substring, MoreStreams, Parallelizer).
Stars: ✭ 236 (+1142.11%)
Mutual labels:  retry
retrygroup
Package retrygroup provides synchronization, Context cancelation for groups of retry goroutines working on subtasks of a common task.
Stars: ✭ 18 (-5.26%)
Mutual labels:  retry
awsretry
Decorate your AWS Boto3 Calls with AWSRetry.backoff(). This will allows your calls to get around the AWS Eventual Consistency Errors.
Stars: ✭ 42 (+121.05%)
Mutual labels:  retry
perseverance
Make your functions 💪 resilient and 🚥 fail-fast to 💩 failures or ⌚ delays
Stars: ✭ 12 (-36.84%)
Mutual labels:  retry
backoff
PHP library providing retry functionality with multiple backoff strategies and jitter support
Stars: ✭ 132 (+594.74%)
Mutual labels:  retry

java-retrying

License FOSSA Status Build Status codecov

java重试, 支持同步/异步, 简单灵活可配, 不依赖第三方库.

基于guava-retrying改造, 增加了异步重试, 同时去掉了第三方依赖, 使用方法基本一致.

名称 JDK 第三方依赖 同步重试 异步重试
guava-retrying 大于等于6 guava,findbugs Y N
java-retrying 大于等于8 Y Y

Quickstart

  • 依赖
<dependency>
    <groupId>com.github.lowzj</groupId>
    <artifactId>java-retrying</artifactId>
    <version>1.2</version>
</dependency>
  • 同步重试
Retryer<Integer> retryer = RetryerBuilder.<Integer>newBuilder()
    .withWaitStrategy(WaitStrategies.fixedWait(100L, TimeUnit.MILLISECONDS))
    .retryIfResult(num -> num != 5)
    .retryIfExceptionOfType(RuntimeException.class)
    .withStopStrategy(StopStrategies.stopAfterAttempt(7))
    .build();

try {
    retryer.call(noRuntimeExceptionAfter(4));
} catch (ExecutionException | RetryException e) {
    e.printStackTrace();
}
  • 异步重试
AsyncRetryer<Integer> asyncRetryer = RetryerBuilder.<Integer>newBuilder()
    .withWaitStrategy(WaitStrategies.fixedWait(100L, TimeUnit.MILLISECONDS))
    .retryIfResult(num -> num != 4)
    .retryIfExceptionOfType(RuntimeException.class)
    .withStopStrategy(StopStrategies.stopAfterAttempt(7))
    .withExecutor(ExecutorsUtil.scheduledExecutorService("example", 1))
    .buildAsyncRetryer();

CompletableFuture<Integer> future = asyncRetryer.call(noRuntimeExceptionAfter(3));

// get the result asynchronously
future.whenComplete((result, error) -> System.out.println(result));

// or get the result synchronously
try {
    System.out.println(future.get());
} catch (InterruptedException | ExecutionException e) {
    e.printStackTrace();
}

其中函数noRuntimeExceptionAfter如下:

private Callable<Integer> noRuntimeExceptionAfter(final int attemptNumber) {
    return new Callable<Integer>() {
        private int count = 0;
        @Override
        public Integer call() throws Exception {
            if (count++ < attemptNumber) {
                throw new RuntimeException("count[" + (count - 1) + "] < attemptNumber[" + attemptNumber + "]");
            }
            return count;
        }
    };
}

LICENSE

Java-retrying is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

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].