APIClientBuilder, AsyncAPIClientBuilderpublic abstract class GenericAPIClientBuilder extends Object
| Modifier and Type | Field | Description |
|---|---|---|
protected String |
apiKey |
|
protected String |
applicationId |
|
protected List<String> |
buildHosts |
|
protected int |
connectTimeout |
|
protected String |
customAgent |
|
protected String |
customAgentVersion |
|
protected Map<String,String> |
customHeaders |
|
protected int |
hostDownTimeout |
|
protected int |
maxConnTotal |
|
protected com.fasterxml.jackson.databind.ObjectMapper |
objectMapper |
|
protected List<String> |
queryHosts |
|
protected Random |
random |
|
protected int |
readTimeout |
| Constructor | Description |
|---|---|
GenericAPIClientBuilder(String applicationId,
String apiKey) |
Initialize this builder with the applicationId and apiKey
|
| Modifier and Type | Method | Description |
|---|---|---|
protected List<String> |
generateBuildHosts() |
|
protected Map<String,String> |
generateHeaders() |
|
protected List<String> |
generateQueryHosts() |
|
GenericAPIClientBuilder |
setBuildHosts(List<String> buildHosts) |
Set the hosts for indexing & building
|
GenericAPIClientBuilder |
setConnectTimeout(int connectTimeout) |
Set the connect timeout of the HTTP client
|
GenericAPIClientBuilder |
setExtraHeader(String key,
String value) |
Set extra headers to the requests
|
GenericAPIClientBuilder |
setHostDownTimeout(int hostDownTimeout) |
Set the retry timeout to detect if a host is down
|
GenericAPIClientBuilder |
setMaxConnTotal(int maxConnTotal) |
Set the maximum of connection, only available for
ApacheAPIClientBuilder and AsyncAPIClientBuilder |
GenericAPIClientBuilder |
setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) |
Set the Jackson ObjectMapper, it overrides the default one and add 2 features: * Enables:
AUTO_CLOSE_JSON_CONTENT * Disables: FAIL_ON_UNKNOWN_PROPERTIES
|
GenericAPIClientBuilder |
setQueryHosts(List<String> queryHosts) |
Set the hosts for search & queries
|
GenericAPIClientBuilder |
setReadTimeout(int readTimeout) |
Set the read timeout of the HTTP client
|
GenericAPIClientBuilder |
setUserAgent(String customAgent,
String customAgentVersion) |
Customize the user agent
|
protected final Random random
protected final String applicationId
protected final String apiKey
protected String customAgent
protected String customAgentVersion
protected int connectTimeout
protected int readTimeout
protected int hostDownTimeout
protected com.fasterxml.jackson.databind.ObjectMapper objectMapper
protected int maxConnTotal
public GenericAPIClientBuilder(@Nonnull String applicationId, @Nonnull String apiKey)
applicationId - APP_ID can be found on https://www.algolia.com/api-keysapiKey - Algolia API_KEY can also be found on https://www.algolia.com/api-keyspublic GenericAPIClientBuilder setUserAgent(@Nonnull String customAgent, @Nonnull String customAgentVersion)
customAgent - key to add to the user agentcustomAgentVersion - value of this key to add to the user agentpublic GenericAPIClientBuilder setExtraHeader(@Nonnull String key, String value)
key - name of the headervalue - value of the headerpublic GenericAPIClientBuilder setConnectTimeout(int connectTimeout)
connectTimeout - the value in mspublic GenericAPIClientBuilder setReadTimeout(int readTimeout)
readTimeout - the value in mspublic GenericAPIClientBuilder setHostDownTimeout(int hostDownTimeout)
hostDownTimeout - the value in mspublic GenericAPIClientBuilder setObjectMapper(@Nonnull com.fasterxml.jackson.databind.ObjectMapper objectMapper)
objectMapper - the mapperpublic GenericAPIClientBuilder setQueryHosts(List<String> queryHosts)
queryHosts - the list of hosts for searchpublic GenericAPIClientBuilder setBuildHosts(List<String> buildHosts)
buildHosts - the list of hosts for indexing/buildingpublic GenericAPIClientBuilder setMaxConnTotal(int maxConnTotal)
ApacheAPIClientBuilder and AsyncAPIClientBuildermaxConnTotal - the max number of connectionsCopyright © 2017. All rights reserved.