public class GeoApiContext
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
GeoApiContext.RequestHandler
RequestHandler is the service provider interface that enables requests to be handled via
switchable back ends.
|
Constructor and Description |
---|
GeoApiContext()
Construct a GeoApiContext with OkHttp.
|
GeoApiContext(GeoApiContext.RequestHandler requestHandler)
Construct a GeoApiContext with the specified strategy for handling requests.
|
Modifier and Type | Method and Description |
---|---|
GeoApiContext |
disableRetries()
Disable retries completely.
|
GeoApiContext |
setApiKey(java.lang.String apiKey) |
GeoApiContext |
setChannel(java.lang.String channel)
Sets the default channel for requests (can be overridden by requests).
|
GeoApiContext |
setConnectTimeout(long timeout,
java.util.concurrent.TimeUnit unit)
Sets the default connect timeout for new connections.
|
GeoApiContext |
setEnterpriseCredentials(java.lang.String clientId,
java.lang.String cryptographicSecret) |
GeoApiContext |
setMaxRetries(java.lang.Integer maxRetries)
Sets the maximum number of times each retry-able errors will be retried.
|
GeoApiContext |
setProxy(java.net.Proxy proxy)
Sets the proxy for new connections.
|
GeoApiContext |
setQueryRateLimit(int maxQps)
Sets the maximum number of queries that will be executed during a 1 second interval.
|
GeoApiContext |
setQueryRateLimit(int maxQps,
int minimumInterval)
Sets the rate at which queries are executed.
|
GeoApiContext |
setReadTimeout(long timeout,
java.util.concurrent.TimeUnit unit)
Sets the default read timeout for new connections.
|
GeoApiContext |
setRetryTimeout(long timeout,
java.util.concurrent.TimeUnit unit)
Sets the cumulative time limit for which retry-able errors will be retried.
|
GeoApiContext |
setWriteTimeout(long timeout,
java.util.concurrent.TimeUnit unit)
Sets the default write timeout for new connections.
|
GeoApiContext |
toggleifExceptionIsAllowedToRetry(java.lang.Class<? extends ApiException> exception,
boolean allowedToRetry)
Allows specific API exceptions to be retried or not retried.
|
public GeoApiContext()
public GeoApiContext(GeoApiContext.RequestHandler requestHandler)
requestHandler
- How to handle URL requests to the Google Maps APIs.OkHttpRequestHandler
,
GaeRequestHandler
public GeoApiContext setApiKey(java.lang.String apiKey)
public GeoApiContext setEnterpriseCredentials(java.lang.String clientId, java.lang.String cryptographicSecret)
public GeoApiContext setChannel(java.lang.String channel)
channel
- The channel to use for analyticspublic GeoApiContext setConnectTimeout(long timeout, java.util.concurrent.TimeUnit unit)
URLConnection.setConnectTimeout(int)
public GeoApiContext setReadTimeout(long timeout, java.util.concurrent.TimeUnit unit)
URLConnection.setReadTimeout(int)
public GeoApiContext setWriteTimeout(long timeout, java.util.concurrent.TimeUnit unit)
public GeoApiContext setRetryTimeout(long timeout, java.util.concurrent.TimeUnit unit)
This operates separately from the count-based setMaxRetries(Integer)
.
public GeoApiContext setMaxRetries(java.lang.Integer maxRetries)
This operates separately from the time-based setRetryTimeout(long, TimeUnit)
.
public GeoApiContext disableRetries()
public GeoApiContext setQueryRateLimit(int maxQps)
maxQps
).public GeoApiContext setQueryRateLimit(int maxQps, int minimumInterval)
maxQps
- The maximum number of queries to execute per second.minimumInterval
- The minimum amount of time, in milliseconds, to pause between requests.
Note that this pause only occurs if the amount of time between requests
has not elapsed naturally.public GeoApiContext toggleifExceptionIsAllowedToRetry(java.lang.Class<? extends ApiException> exception, boolean allowedToRetry)
public GeoApiContext setProxy(java.net.Proxy proxy)
proxy
- The proxy to be used by the underlying HTTP client.