public abstract class BaseRetryInterceptor extends Object implements okhttp3.Interceptor
| 限定符和类型 | 字段和说明 |
|---|---|
private boolean |
enableGlobalRetry |
private int |
globalIntervalMs |
private int |
globalMaxRetries |
private RetryRule[] |
globalRetryRules |
private static int |
LIMIT_RETRIES |
| 构造器和说明 |
|---|
BaseRetryInterceptor() |
| 限定符和类型 | 方法和说明 |
|---|---|
private Retry |
getRetry(Method method) |
okhttp3.Response |
intercept(okhttp3.Interceptor.Chain chain) |
protected abstract okhttp3.Response |
retryIntercept(int maxRetries,
int intervalMs,
RetryRule[] retryRules,
okhttp3.Interceptor.Chain chain)
process a retryable request
The access level here is set to protected, which can facilitate business personalized expansion
这里访问级别设置为protected,可方便业务个性化扩展
|
void |
setEnableGlobalRetry(boolean enableGlobalRetry) |
void |
setGlobalIntervalMs(int globalIntervalMs) |
void |
setGlobalMaxRetries(int globalMaxRetries) |
void |
setGlobalRetryRules(RetryRule[] globalRetryRules) |
private boolean enableGlobalRetry
private int globalMaxRetries
private int globalIntervalMs
private RetryRule[] globalRetryRules
private static final int LIMIT_RETRIES
public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain)
throws IOException
intercept 在接口中 okhttp3.InterceptorIOExceptionprotected abstract okhttp3.Response retryIntercept(int maxRetries,
int intervalMs,
RetryRule[] retryRules,
okhttp3.Interceptor.Chain chain)
maxRetries - 最大重试次数。Maximum number of retriesintervalMs - 重试时间间隔。Retry intervalretryRules - 重试规则。Retry ruleschain - 执行链。Execution chainpublic void setEnableGlobalRetry(boolean enableGlobalRetry)
public void setGlobalMaxRetries(int globalMaxRetries)
public void setGlobalIntervalMs(int globalIntervalMs)
public void setGlobalRetryRules(RetryRule[] globalRetryRules)
Copyright © 2021. All rights reserved.