Skip to content

Commit 3d9f6b4

Browse files
author
周旭
committed
Revert "移除 RetryPolicy,留待 v2.5.1 实现"
This reverts commit 4611037
1 parent 3ede05d commit 3d9f6b4

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.ejlchina.okhttps;
2+
3+
4+
import java.io.IOException;
5+
6+
/**
7+
* @since 2.5.0
8+
* 重试策略
9+
*/
10+
public interface RetryPolicy {
11+
12+
/**
13+
*执行策略
14+
* @param condition 当前的重试条件
15+
* @param tryOpt 重试选择器(要么重试、要么放弃)
16+
*/
17+
void doPolicy(Condition condition, TryOpt tryOpt);
18+
19+
/**
20+
* 重试条件
21+
*/
22+
interface Condition {
23+
24+
/**
25+
* @return 已重试次数
26+
*/
27+
int getRetryTimes();
28+
29+
/**
30+
* @return 当前的请求任务
31+
*/
32+
HttpTask<?> getTask();
33+
34+
/**
35+
* @return 当前的 Http 结果
36+
*/
37+
HttpResult getHttpResult();
38+
39+
/**
40+
* @return WebSocket 关闭原因
41+
*/
42+
WebSocket.Close getClose();
43+
44+
/**
45+
* @return 发生的 IO 异常
46+
*/
47+
IOException getIOException();
48+
49+
}
50+
51+
/**
52+
* 重试选择
53+
*/
54+
interface TryOpt {
55+
56+
/**
57+
* 再试一次
58+
*/
59+
void tryAgain();
60+
61+
/**
62+
* 完成,不再重试
63+
*/
64+
void justDone();
65+
66+
}
67+
68+
}

0 commit comments

Comments
 (0)