Package io.tarantool.driver.api
Interface TarantoolClientBuilder
-
- All Superinterfaces:
TarantoolClientConfigurator<TarantoolClientBuilder>
- All Known Implementing Classes:
TarantoolClientBuilderImpl
public interface TarantoolClientBuilder extends TarantoolClientConfigurator<TarantoolClientBuilder>
Tarantool client builder interface.Provides a single entry point for building all types of Tarantool clients.
-
-
Method Summary
All Methods Instance Methods Abstract 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 connections)
Specify the number of connections per one Tarantool server.TarantoolClientBuilder
withConnectionSelectionStrategy(ConnectionSelectionStrategyFactory connectionSelectionStrategyFactory)
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 tarantoolCredentials)
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 interface io.tarantool.driver.api.TarantoolClientConfigurator
withProxyMethodMapping, withProxyMethodMapping, withRetrying, withRetryingByNumberOfAttempts, withRetryingByNumberOfAttempts, withRetryingByNumberOfAttempts, withRetryingIndefinitely, withRetryingIndefinitely
-
-
-
-
Method Detail
-
withAddress
TarantoolClientBuilder withAddress(String host)
Specify a single host of a Tarantool server. The default port 3301 will be used.- Parameters:
host
- Tarantool server host- Returns:
- this instance of builder
TarantoolClientBuilder
-
withAddress
TarantoolClientBuilder withAddress(String host, int port)
Specify a single host and a port of a Tarantool server.- Parameters:
host
- Tarantool server hostport
- Tarantool server port- Returns:
- this instance of builder
TarantoolClientBuilder
-
withAddress
TarantoolClientBuilder withAddress(InetSocketAddress socketAddress)
Specify a Tarantool server address.- Parameters:
socketAddress
- remote server address- Returns:
- this instance of builder
TarantoolClientBuilder
-
withAddresses
TarantoolClientBuilder withAddresses(TarantoolServerAddress... address)
Specify one or more Tarantool server addresses.- Parameters:
address
- list of addresses of Tarantool instances- Returns:
- this instance of builder
TarantoolClientBuilder
-
withAddresses
TarantoolClientBuilder withAddresses(List<TarantoolServerAddress> addressList)
Specify a list of Tarantool server addresses. In a sharded cluster this is usually a list of router instances addresses.- Parameters:
addressList
- list of Tarantool instance addresses- Returns:
- this instance of builder
TarantoolClientBuilder
-
withAddressProvider
TarantoolClientBuilder withAddressProvider(TarantoolClusterAddressProvider addressProvider)
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.- Parameters:
addressProvider
-TarantoolClusterAddressProvider
- Returns:
- this instance of builder
TarantoolClientBuilder
-
withCredentials
TarantoolClientBuilder withCredentials(TarantoolCredentials tarantoolCredentials)
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.- Parameters:
tarantoolCredentials
- credentials for all Tarantool server instances- Returns:
- this instance of builder
TarantoolClientBuilder
-
withCredentials
TarantoolClientBuilder withCredentials(String user, String password)
Specify user credentials for password-based authentication in a Tarantool server.- Parameters:
user
- user to authenticate withpassword
- password to authenticate with- Returns:
- this instance of builder
TarantoolClientBuilder
- See Also:
withCredentials(TarantoolCredentials tarantoolCredentials)
-
withConnections
TarantoolClientBuilder withConnections(int connections)
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.- Parameters:
connections
- the number of connections per one server- Returns:
- this instance of builder
TarantoolClientBuilder
-
withDefaultMessagePackMapperConfiguration
TarantoolClientBuilder withDefaultMessagePackMapperConfiguration(UnaryOperator<MessagePackMapperBuilder> mapperBuilder)
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
.- 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
TarantoolClientBuilder withMessagePackMapper(MessagePackMapper mapper)
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
.- Parameters:
mapper
- configuredMessagePackMapper
instance- Returns:
- this instance of builder
TarantoolClientBuilder
- See Also:
TarantoolClientConfig.setMessagePackMapper(MessagePackMapper)
-
withRequestTimeout
TarantoolClientBuilder withRequestTimeout(int requestTimeout)
Specify a request timeout. The default is 2000 milliseconds.- 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
TarantoolClientBuilder withConnectTimeout(int connectTimeout)
Specify a connection timeout. The default is 1000 milliseconds.- Parameters:
connectTimeout
- the timeout for connecting to the Tarantool server, in milliseconds- Returns:
- this instance of builder
TarantoolClientBuilder
- See Also:
TarantoolClientConfig.setConnectTimeout(int)
-
withReadTimeout
TarantoolClientBuilder withReadTimeout(int readTimeout)
Specify a response reading timeout. The default is 1000 milliseconds.- 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
TarantoolClientBuilder withConnectionSelectionStrategy(ConnectionSelectionStrategyFactory connectionSelectionStrategyFactory)
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.- Parameters:
connectionSelectionStrategyFactory
- connection selection strategy factory instance- Returns:
- this instance of builder
TarantoolClientBuilder
-
withConnectionSelectionStrategy
TarantoolClientBuilder withConnectionSelectionStrategy(TarantoolConnectionSelectionStrategyType connectionSelectionStrategyType)
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).- Parameters:
connectionSelectionStrategyType
- built-in connection selection strategy factory type- Returns:
- this instance of builder
TarantoolClientBuilder
-
withSslContext
TarantoolClientBuilder withSslContext(io.netty.handler.ssl.SslContext sslContext)
Specify SslContext with settings for establishing SSL/TLS connection between Tarantool- Parameters:
sslContext
-SslContext
instance- Returns:
- this instance of builder
TarantoolClientBuilder
-
withTarantoolClientConfig
TarantoolClientBuilder withTarantoolClientConfig(TarantoolClientConfig config)
Specify a tarantool client configIt overrides previous settings for config
- Parameters:
config
- tarantool client config- Returns:
- this instance of builder
TarantoolClientBuilder
-
build
TarantoolClient<TarantoolTuple,TarantoolResult<TarantoolTuple>> build()
Build the configured Tarantool client instance. Call this when you have specified all necessary settings.- Specified by:
build
in interfaceTarantoolClientConfigurator<TarantoolClientBuilder>
- Returns:
- instance of tarantool tuple client
TarantoolClient
-
-