File tree Expand file tree Collapse file tree
okhttps/src/main/java/com/ejlchina/okhttps Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments