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();