Package dev.failsafe.okhttp
Class FailsafeCall
- java.lang.Object
-
- dev.failsafe.okhttp.FailsafeCall
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFailsafeCall.FailsafeCallBuilder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()Cancels the call.FailsafeCallclone()Returns a clone of the FailsafeCall.okhttp3.Responseexecute()Executes the call until a successful response is returned or the configured policies are exceeded.CompletableFuture<okhttp3.Response>executeAsync()Executes the call asynchronously until a successful result is returned or the configured policies are exceeded.booleanisCancelled()Returns whether the call has been cancelled.booleanisExecuted()Returns whether the call has been executed.static FailsafeCall.FailsafeCallBuilderwith(FailsafeExecutor<okhttp3.Response> failsafeExecutor)Returns a FailsafeCallBuilder for thefailsafeExecutor.static <P extends Policy<okhttp3.Response>>
FailsafeCall.FailsafeCallBuilderwith(P outerPolicy, P... policies)Returns a FailsafeCallBuilder for theouterPolicyandpolicies.
-
-
-
Method Detail
-
with
@SafeVarargs public static <P extends Policy<okhttp3.Response>> FailsafeCall.FailsafeCallBuilder with(P outerPolicy, P... policies)
Returns a FailsafeCallBuilder for theouterPolicyandpolicies. SeeFailsafe.with(Policy, Policy[])for docs on how policy composition works.- Type Parameters:
P- policy type- Throws:
NullPointerException- ifcallorouterPolicyare null
-
with
public static FailsafeCall.FailsafeCallBuilder with(FailsafeExecutor<okhttp3.Response> failsafeExecutor)
Returns a FailsafeCallBuilder for thefailsafeExecutor.- Throws:
NullPointerException- iffailsafeExecutoris null
-
cancel
public void cancel()
Cancels the call.
-
clone
public FailsafeCall clone()
Returns a clone of the FailsafeCall.
-
execute
public okhttp3.Response execute() throws IOExceptionExecutes the call until a successful response is returned or the configured policies are exceeded. To avoid leaking resources callers shouldclosethe Response which in turn will close the underlying ResponseBody.- Throws:
IllegalStateException- if the call has already been executedIOException- if the request could not be executed due to cancellation, a connectivity problem, or timeoutFailsafeException- if the execution fails with a checked Exception.Throwable.getCause()can be used to learn the underlying checked exception.
-
executeAsync
public CompletableFuture<okhttp3.Response> executeAsync()
Executes the call asynchronously until a successful result is returned or the configured policies are exceeded. To avoid leaking resources callers shouldclosethe Response which in turn will close the underlying ResponseBody.
-
isCancelled
public boolean isCancelled()
Returns whether the call has been cancelled.
-
isExecuted
public boolean isExecuted()
Returns whether the call has been executed.
-
-