Package io.tarantool.driver.core
Class TarantoolClientBuilderImpl
- java.lang.Object
-
- io.tarantool.driver.core.TarantoolClientConfiguratorImpl<TarantoolClientBuilder>
-
- io.tarantool.driver.core.TarantoolClientBuilderImpl
-
- All Implemented Interfaces:
TarantoolClientBuilder
,TarantoolClientConfigurator<TarantoolClientBuilder>
public class TarantoolClientBuilderImpl extends TarantoolClientConfiguratorImpl<TarantoolClientBuilder> implements TarantoolClientBuilder
Tarantool client builder implementation.
-
-
Field Summary
-
Fields inherited from class io.tarantool.driver.core.TarantoolClientConfiguratorImpl
mappingConfig, retryPolicyFactory
-
-
Constructor Summary
Constructors Constructor Description TarantoolClientBuilderImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TarantoolClient<TarantoolTuple,TarantoolResult<TarantoolTuple>>
build()
Build the configured Tarantool client instance.TarantoolClientBuilder
withAddress(String host)
Specify a single host of a Tarantool server.TarantoolClientBuilder
withAddress(String host, int port)
Specify a single host and a port of a Tarantool server.TarantoolClientBuilder
withAddress(InetSocketAddress socketAddress)
Specify a Tarantool server address.TarantoolClientBuilder
withAddresses(TarantoolServerAddress... address)
Specify one or more Tarantool server addresses.TarantoolClientBuilder
withAddresses(List<TarantoolServerAddress> addressList)
Specify a list of Tarantool server addresses.TarantoolClientBuilder
withAddressProvider(TarantoolClusterAddressProvider addressProvider)
Specify a provider for Tarantool server addresses.TarantoolClientBuilder
withConnections(int numberOfConnections)
Specify the number of connections per one Tarantool server.TarantoolClientBuilder
withConnectionSelectionStrategy(ConnectionSelectionStrategyFactory connectionSelectionStrategy)
Specify a custom connection selection strategy factory.TarantoolClientBuilder
withConnectionSelectionStrategy(TarantoolConnectionSelectionStrategyType connectionSelectionStrategyType)
Select a built-in connection selection strategy factory.TarantoolClientBuilder
withConnectTimeout(int connectTimeout)
Specify a connection timeout.TarantoolClientBuilder
withCredentials(TarantoolCredentials credentials)
Specify user credentials for authentication in a Tarantool server.TarantoolClientBuilder
withCredentials(String user, String password)
Specify user credentials for password-based authentication in a Tarantool server.TarantoolClientBuilder
withDefaultMessagePackMapperConfiguration(UnaryOperator<MessagePackMapperBuilder> mapperBuilder)
Specify a configuration for mapping between Java objects and MessagePack entities.TarantoolClientBuilder
withMessagePackMapper(MessagePackMapper mapper)
Specify a mapper between Java objects and MessagePack entities.TarantoolClientBuilder
withReadTimeout(int readTimeout)
Specify a response reading timeout.TarantoolClientBuilder
withRequestTimeout(int requestTimeout)
Specify a request timeout.TarantoolClientBuilder
withSslContext(io.netty.handler.ssl.SslContext sslContext)
Specify SslContext with settings for establishing SSL/TLS connection between TarantoolTarantoolClientBuilder
withTarantoolClientConfig(TarantoolClientConfig config)
Specify a tarantool client config-
Methods inherited from class io.tarantool.driver.core.TarantoolClientConfiguratorImpl
decorate, withProxyMethodMapping, withProxyMethodMapping, withRetrying, withRetryingByNumberOfAttempts, withRetryingByNumberOfAttempts, withRetryingByNumberOfAttempts, withRetryingIndefinitely, withRetryingIndefinitely
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.tarantool.driver.api.TarantoolClientConfigurator
withProxyMethodMapping, withProxyMethodMapping, withRetrying, withRetryingByNumberOfAttempts, withRetryingByNumberOfAttempts, withRetryingByNumberOfAttempts, withRetryingIndefinitely, withRetryingIndefinitely
-
-
-
-
Method Detail
-
withAddress
public TarantoolClientBuilder withAddress(String host)
Description copied from interface:TarantoolClientBuilder
Specify a single host of a Tarantool server. The default port 3301 will be used.- Specified by:
withAddress
in interfaceTarantoolClientBuilder
- Parameters:
host
- Tarantool server host- Returns:
- this instance of builder
TarantoolClientBuilder
-
withAddress
public TarantoolClientBuilder withAddress(String host, int port)
Description copied from interface:TarantoolClientBuilder
Specify a single host and a port of a Tarantool server.- Specified by:
withAddress
in interfaceTarantoolClientBuilder
- Parameters:
host
- Tarantool server hostport
- Tarantool server port- Returns:
- this instance of builder
TarantoolClientBuilder
-
withAddress
public TarantoolClientBuilder withAddress(InetSocketAddress socketAddress)
Description copied from interface:TarantoolClientBuilder
Specify a Tarantool server address.- Specified by:
withAddress
in interfaceTarantoolClientBuilder
- Parameters:
socketAddress
- remote server address- Returns:
- this instance of builder
TarantoolClientBuilder
-
withAddresses
public TarantoolClientBuilder withAddresses(TarantoolServerAddress... address)
Description copied from interface:TarantoolClientBuilder
Specify one or more Tarantool server addresses.- Specified by:
withAddresses
in interfaceTarantoolClientBuilder
- Parameters:
address
- list of addresses of Tarantool instances- Returns:
- this instance of builder
TarantoolClientBuilder
-
withAddresses
public TarantoolClientBuilder withAddresses(List<TarantoolServerAddress> addressList)
Description copied from interface:TarantoolClientBuilder
Specify a list of Tarantool server addresses. In a sharded cluster this is usually a list of router instances addresses.- Specified by:
withAddresses
in interfaceTarantoolClientBuilder
- Parameters:
addressList
- list of Tarantool instance addresses- Returns:
- this instance of builder
TarantoolClientBuilder
-
withAddressProvider
public TarantoolClientBuilder withAddressProvider(TarantoolClusterAddressProvider addressProvider)
Description copied from interface:TarantoolClientBuilder
Specify a provider for Tarantool server addresses. The typical usage of a provider is dynamic retrieving of the addresses from some configuration or discovery manager like etcd, ZooKeeper, or a special Tarantool instance. The actual list of addresses will then be retrieved each time a new connection is being established.- Specified by:
withAddressProvider
in interfaceTarantoolClientBuilder
- Parameters:
addressProvider
-TarantoolClusterAddressProvider
- Returns:
- this instance of builder
TarantoolClientBuilder
-
withCredentials
public TarantoolClientBuilder withCredentials(String user, String password)
Description copied from interface:TarantoolClientBuilder
Specify user credentials for password-based authentication in a Tarantool server.- Specified by:
withCredentials
in interfaceTarantoolClientBuilder
- Parameters:
user
- user to authenticate withpassword
- password to authenticate with- Returns:
- this instance of builder
TarantoolClientBuilder
- See Also:
TarantoolClientBuilder.withCredentials(TarantoolCredentials tarantoolCredentials)
-
withCredentials
public TarantoolClientBuilder withCredentials(TarantoolCredentials credentials)
Description copied from interface:TarantoolClientBuilder
Specify user credentials for authentication in a Tarantool server. Important: these credentials will be used for all Tarantool server instances, which addresses are returned by a service provider or are directly specified in the client configuration, so make sure that all instances to be connected can authenticate with the specified credentials.- Specified by:
withCredentials
in interfaceTarantoolClientBuilder
- Parameters:
credentials
- credentials for all Tarantool server instances- Returns:
- this instance of builder
TarantoolClientBuilder
-
withConnections
public TarantoolClientBuilder withConnections(int numberOfConnections)
Description copied from interface:TarantoolClientBuilder
Specify the number of connections per one Tarantool server. The default value is 1. More connections may help if a request can stuck on the server side or if the request payloads are big. Important: the total number of open connections will be kept close to the specified number of connections times the number of server addresses. In a normal working mode, the number of connections opened to each server will be equal to this option value, however, an actual number may differ when the connections go down or up.- Specified by:
withConnections
in interfaceTarantoolClientBuilder
- Parameters:
numberOfConnections
- the number of connections per one server- Returns:
- this instance of builder
TarantoolClientBuilder
-
withDefaultMessagePackMapperConfiguration
public TarantoolClientBuilder withDefaultMessagePackMapperConfiguration(UnaryOperator<MessagePackMapperBuilder> mapperBuilder)
Description copied from interface:TarantoolClientBuilder
Specify a configuration for mapping between Java objects and MessagePack entities.This method takes a lambda as an argument, where the mapperBuilder is
seeDefaultMessagePackMapper.Builder
.DefaultMessagePackMapperFactory
.- Specified by:
withDefaultMessagePackMapperConfiguration
in interfaceTarantoolClientBuilder
- Parameters:
mapperBuilder
- builder provider instance, e.g. a lambda function taking the builder forMessagePackMapper
instance- Returns:
- this instance of builder
TarantoolClientBuilder
- See Also:
TarantoolClientConfig.setMessagePackMapper(MessagePackMapper)
-
withMessagePackMapper
public TarantoolClientBuilder withMessagePackMapper(MessagePackMapper mapper)
Description copied from interface:TarantoolClientBuilder
Specify a mapper between Java objects and MessagePack entities. The mapper contains converters for simple and complex tuple field types and for the entire tuples into custom Java objects. This mapper is used by default if a custom mapper is not passed to a specific operation. You may build and pass here your custom mapper or add some converters to a default one, seeDefaultMessagePackMapperFactory
.- Specified by:
withMessagePackMapper
in interfaceTarantoolClientBuilder
- Parameters:
mapper
- configuredMessagePackMapper
instance- Returns:
- this instance of builder
TarantoolClientBuilder
- See Also:
TarantoolClientConfig.setMessagePackMapper(MessagePackMapper)
-
withRequestTimeout
public TarantoolClientBuilder withRequestTimeout(int requestTimeout)
Description copied from interface:TarantoolClientBuilder
Specify a request timeout. The default is 2000 milliseconds.- Specified by:
withRequestTimeout
in interfaceTarantoolClientBuilder
- Parameters:
requestTimeout
- the timeout for receiving a response from the Tarantool server, in milliseconds- Returns:
- this instance of builder
TarantoolClientBuilder
- See Also:
TarantoolClientConfig.setRequestTimeout(int)
-
withConnectTimeout
public TarantoolClientBuilder withConnectTimeout(int connectTimeout)
Description copied from interface:TarantoolClientBuilder
Specify a connection timeout. The default is 1000 milliseconds.- Specified by:
withConnectTimeout
in interfaceTarantoolClientBuilder
- Parameters:
connectTimeout
- the timeout for connecting to the Tarantool server, in milliseconds- Returns:
- this instance of builder
TarantoolClientBuilder
- See Also:
TarantoolClientConfig.setConnectTimeout(int)
-
withReadTimeout
public TarantoolClientBuilder withReadTimeout(int readTimeout)
Description copied from interface:TarantoolClientBuilder
Specify a response reading timeout. The default is 1000 milliseconds.- Specified by:
withReadTimeout
in interfaceTarantoolClientBuilder
- Parameters:
readTimeout
- the timeout for reading the responses from Tarantool server, in milliseconds- Returns:
- this instance of builder
TarantoolClientBuilder
- See Also:
TarantoolClientConfig.setReadTimeout(int)
-
withConnectionSelectionStrategy
public TarantoolClientBuilder withConnectionSelectionStrategy(TarantoolConnectionSelectionStrategyType connectionSelectionStrategyType)
Description copied from interface:TarantoolClientBuilder
Select a built-in connection selection strategy factory. The default strategy types include simple round-robin algorithms, good enough for balancing the requests between several connections with a single server (ROUND_ROBIN) or multiple servers (PARALLEL_ROUND_ROBIN).- Specified by:
withConnectionSelectionStrategy
in interfaceTarantoolClientBuilder
- Parameters:
connectionSelectionStrategyType
- built-in connection selection strategy factory type- Returns:
- this instance of builder
TarantoolClientBuilder
-
withSslContext
public TarantoolClientBuilder withSslContext(io.netty.handler.ssl.SslContext sslContext)
Description copied from interface:TarantoolClientBuilder
Specify SslContext with settings for establishing SSL/TLS connection between Tarantool- Specified by:
withSslContext
in interfaceTarantoolClientBuilder
- Parameters:
sslContext
-SslContext
instance- Returns:
- this instance of builder
TarantoolClientBuilder
-
withConnectionSelectionStrategy
public TarantoolClientBuilder withConnectionSelectionStrategy(ConnectionSelectionStrategyFactory connectionSelectionStrategy)
Description copied from interface:TarantoolClientBuilder
Specify a custom connection selection strategy factory. A connection selection strategy encapsulates an algorithm of selecting the next connection from the pool of available ones for performing the next request.- Specified by:
withConnectionSelectionStrategy
in interfaceTarantoolClientBuilder
- Parameters:
connectionSelectionStrategy
- connection selection strategy factory instance- Returns:
- this instance of builder
TarantoolClientBuilder
-
withTarantoolClientConfig
public TarantoolClientBuilder withTarantoolClientConfig(TarantoolClientConfig config)
Description copied from interface:TarantoolClientBuilder
Specify a tarantool client configIt overrides previous settings for config
- Specified by:
withTarantoolClientConfig
in interfaceTarantoolClientBuilder
- Parameters:
config
- tarantool client config- Returns:
- this instance of builder
TarantoolClientBuilder
-
build
public TarantoolClient<TarantoolTuple,TarantoolResult<TarantoolTuple>> build()
Description copied from interface:TarantoolClientConfigurator
Build the configured Tarantool client instance. Call this when you have specified all necessary settings.- Specified by:
build
in interfaceTarantoolClientBuilder
- Specified by:
build
in interfaceTarantoolClientConfigurator<TarantoolClientBuilder>
- Overrides:
build
in classTarantoolClientConfiguratorImpl<TarantoolClientBuilder>
- Returns:
- instance of tarantool tuple client
TarantoolClient
-
-