Package ai.nextbillion.maps.internal
Class GaePendingResult<T,R extends ApiResponse<T>>
java.lang.Object
ai.nextbillion.maps.internal.GaePendingResult<T,R>
- All Implemented Interfaces:
PendingResult<T>
public class GaePendingResult<T,R extends ApiResponse<T>> extends java.lang.Object implements PendingResult<T>
A PendingResult backed by a HTTP call executed by Google App Engine URL Fetch capability, a
deserialization step using Gson, and a retry policy.
T is the type of the result of this pending result, and R is the type of the
request.
-
Nested Class Summary
Nested classes/interfaces inherited from interface ai.nextbillion.maps.PendingResult
PendingResult.Callback<T> -
Constructor Summary
Constructors Constructor Description GaePendingResult(com.google.appengine.api.urlfetch.HTTPRequest request, com.google.appengine.api.urlfetch.URLFetchService client, java.lang.Class<R> responseClass, com.google.gson.FieldNamingPolicy fieldNamingPolicy, long errorTimeOut, java.lang.Integer maxRetries, ExceptionsAllowedToRetry exceptionsAllowedToRetry, RequestMetrics metrics) -
Method Summary
Modifier and Type Method Description Tawait()Performs the request synchronously.TawaitIgnoreError()Performs the request synchronously, ignoring exceptions while performing the request and errors returned by the server.voidcancel()Attempts to cancel the request.voidsetCallback(PendingResult.Callback<T> callback)
-
Constructor Details
-
GaePendingResult
public GaePendingResult(com.google.appengine.api.urlfetch.HTTPRequest request, com.google.appengine.api.urlfetch.URLFetchService client, java.lang.Class<R> responseClass, com.google.gson.FieldNamingPolicy fieldNamingPolicy, long errorTimeOut, java.lang.Integer maxRetries, ExceptionsAllowedToRetry exceptionsAllowedToRetry, RequestMetrics metrics)- Parameters:
request- HTTP request to execute.client- The client used to execute the request.responseClass- Model class to unmarshal JSON body content.fieldNamingPolicy- FieldNamingPolicy for unmarshaling JSON.errorTimeOut- Number of milliseconds to re-send erroring requests.maxRetries- Number of times allowed to re-send erroring requests.exceptionsAllowedToRetry- exceptionsAllowedToRetrymetrics- metrics
-
-
Method Details
-
setCallback
Description copied from interface:PendingResultPerforms the request asynchronously, callingonResultoronFailureafter the request has been completed.- Specified by:
setCallbackin interfacePendingResult<T>- Parameters:
callback- The callback to call on completion.
-
await
Description copied from interface:PendingResultPerforms the request synchronously.- Specified by:
awaitin interfacePendingResult<T>- Returns:
- The result.
- Throws:
ApiException- Thrown if the API Returned result is an error.java.io.IOException- Thrown when an I/O exception of some sort has occurred.java.lang.InterruptedException- Thrown when a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted.
-
awaitIgnoreError
Description copied from interface:PendingResultPerforms the request synchronously, ignoring exceptions while performing the request and errors returned by the server.- Specified by:
awaitIgnoreErrorin interfacePendingResult<T>- Returns:
- The result, or null if there was any error or exception ignored.
-
cancel
public void cancel()Description copied from interface:PendingResultAttempts to cancel the request.- Specified by:
cancelin interfacePendingResult<T>
-