Package io.tarantool.driver.api
Interface TarantoolClientFactory
-
public interface TarantoolClientFactory
Tarantool client factory interface.It provides a builder interface helping to create the basic Tarantool client types while hiding the internal client implementation details from the user.
Here are some examples of using this client factory:
// Create a client instance with default settings. This client can connect to a local Tarantool process listening the default port 3301 (do not forget enabling it by executing this command in console: `box.cfg{ listen = 3301 }`). TarantoolClientFactory.createClient().build(); // Create a client instance for a single server with custom credentials TarantoolClientFactory.createClient() .withAddress(new TarantoolServerAddress("123.123.123.123", 3333)) .withCredentials(new SimpleTarantoolCredentials("root", "passwd")) .build(); // Create a client instance with custom proxy operations mapping TarantoolClientFactory.createClient() .withAddress(new TarantoolServerAddress("123.123.123.123", 3333)) .withCredentials(new SimpleTarantoolCredentials("root", "passwd")) .withProxyMethodMapping(builder -> builder.withDeleteFunctionName("custom_delete")) .build(); // Create a client instance with request retry policy TarantoolClientFactory.createClient() .withAddress(new TarantoolServerAddress("123.123.123.123", 3333)) .withCredentials(new SimpleTarantoolCredentials("root", "passwd")) .withRetryingByNumberOfAttempts(5, throwable -> throwable.getMessage().equals("Some error"), policy -> policy.withDelay(500) .withRequestTimeout(1000) .withConnectionSelectionStrategy(PARALLEL_ROUND_ROBIN) .build(); // Create a client instance with proxy operations mapping and request retry policy TarantoolClientFactory.createClient() .withAddress(new TarantoolServerAddress("123.123.123.123", 3333)) .withCredentials(new SimpleTarantoolCredentials("root", "passwd")) .withConnectionSelectionStrategy(PARALLEL_ROUND_ROBIN) .withProxyMethodMapping(builder -> builder.withReplaceFunctionName("custom_replace") .withTruncateFunctionName("create")) .withRetryingByNumberOfAttempts(5, throwable -> throwable.getMessage().equals("Some error"), policy -> policy.withDelay(500) .withRequestTimeout(1000) ).build(); // Create a client instance with request retry policy from an existing configured client TarantoolClientFactory.configureClient(client) .withRetryingByNumberOfAttempts(5, throwable -> throwable.getMessage().equals("Some error"), policy -> policy.withDelay(500) .withRequestTimeout(1000) ).build(); // Create a client instance with proxy operations mapping from an existing configured client TarantoolClientFactory.configureClient(client) .withProxyMethodMapping(mapping -> mapping.withDeleteFunctionName("custom_delete")) .build();
-
-
Method Summary
Static Methods Modifier and Type Method Description static <T extends TarantoolClientConfigurator<T>>
TconfigureClient(TarantoolClient<TarantoolTuple,TarantoolResult<TarantoolTuple>> client)
Configure an existing client instance and return a copy of it.static TarantoolClientBuilder
createClient()
Create a new client instance.
-
-
-
Method Detail
-
createClient
static TarantoolClientBuilder createClient()
Create a new client instance. Provides a builder interface.- Returns:
- Tarantool client builder
TarantoolClientBuilder
-
configureClient
static <T extends TarantoolClientConfigurator<T>> T configureClient(TarantoolClient<TarantoolTuple,TarantoolResult<TarantoolTuple>> client)
Configure an existing client instance and return a copy of it. Provides a builder interface.- Type Parameters:
T
- configurator builder type- Parameters:
client
- client instance- Returns:
- Tarantool client configurator
TarantoolClientConfigurator
-
-