All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.tarantool.driver.api.TarantoolClientConfigurator Maven / Gradle / Ivy

Go to download

Tarantool Cartridge driver for Tarantool versions 1.10+ based on Netty framework

There is a newer version: 0.14.0
Show newest version
package io.tarantool.driver.api;

import io.tarantool.driver.api.proxy.ProxyOperationsMappingConfig;
import io.tarantool.driver.api.retry.RequestRetryPolicyFactory;
import io.tarantool.driver.api.retry.TarantoolRequestRetryPolicies;
import io.tarantool.driver.api.tuple.TarantoolTuple;

import java.util.concurrent.Executor;
import java.util.function.Predicate;
import java.util.function.UnaryOperator;

/**
 * Tarantool client configurator interface.
 * 

* Provides a single entry point for configuring all types of Tarantool clients. * * @author Oleg Kuznetsov */ public interface TarantoolClientConfigurator> { /** * Specify using the default CRUD proxy operations mapping configuration. For using the default operations mapping, * make sure the tarantool/crud module is installed as a dependency and enabled in your application. * * @return this instance of builder {@link TarantoolClientConfigurator} */ SELF withProxyMethodMapping(); /** * Configure a custom operations proxy configuration. * This configuration allows specifying custom Lua function names callable on the Tarantool server, * for replacing the default space operations with these functions calls. This allows, for example, * replacing the default schema retrieving method or writing a custom "insert" implementation. * * @param builder builder provider instance, e.g. a lambda function taking the builder * @return this instance of builder {@link TarantoolClientConfigurator} */ SELF withProxyMethodMapping(UnaryOperator builder); /** * Specify the number of retry attempts for each request. * * @param numberOfAttempts the number of retry attempts for each request * @return this instance of builder {@link TarantoolClientConfigurator} */ SELF withRetryingByNumberOfAttempts(int numberOfAttempts); /** * Configure the attempts bound request retry policy. * Only the requests that failed with known network exceptions will be retried by default. * * @param numberOfAttempts the number of retry attempts for each request * @param policy builder provider for {@link TarantoolRequestRetryPolicies.AttemptsBoundRetryPolicy}, * e.g. a lambda function taking the builder * @return this instance of builder {@link TarantoolClientConfigurator} */ SELF withRetryingByNumberOfAttempts( int numberOfAttempts, UnaryOperator>> policy); /** * Configure the attempts bound request retry policy. * Only the requests that failed with known network exceptions will be retried by default. * * @param numberOfAttempts the number of retry attempts for each request * @param policy builder provider for {@link TarantoolRequestRetryPolicies.AttemptsBoundRetryPolicy}, * e.g. a lambda function taking the builder * @param executor executor service for retry callbacks * @return this instance of builder {@link TarantoolClientConfigurator} */ SELF withRetryingByNumberOfAttempts( int numberOfAttempts, UnaryOperator>> policy, Executor executor); /** * Configure the attempts bound request retry policy. * * @param numberOfAttempts the number of retry attempts for each request * @param exceptionsCheck function checking whether the given exception may be retried * @param policy builder provider for {@link TarantoolRequestRetryPolicies.AttemptsBoundRetryPolicy}, * e.g. a lambda function taking the builder * @param callback type for exceptions check * @return this instance of builder {@link TarantoolClientConfigurator} */ > SELF withRetryingByNumberOfAttempts( int numberOfAttempts, T exceptionsCheck, UnaryOperator> policy); /** * Configure the attempts bound request retry policy. * * @param numberOfAttempts the number of retry attempts for each request * @param exceptionsCheck function checking whether the given exception may be retried * @param policy builder provider for {@link TarantoolRequestRetryPolicies.AttemptsBoundRetryPolicy}, * e.g. a lambda function taking the builder * @param executor executor service for retry callbacks * @param callback type for exceptions check * @return this instance of builder {@link TarantoolClientConfigurator} */ > SELF withRetryingByNumberOfAttempts( int numberOfAttempts, T exceptionsCheck, UnaryOperator> policy, Executor executor); /** * Configure the infinite request retry policy. * Only the requests that failed with known network exceptions will be retried by default. * * @param policy builder provider for {@link TarantoolRequestRetryPolicies.InfiniteRetryPolicy}, * e.g. a lambda function taking the builder * @return this instance of builder {@link TarantoolClientConfigurator} */ SELF withRetryingIndefinitely( UnaryOperator>> policy); /** * Configure the infinite request retry policy. * Only the requests that failed with known network exceptions will be retried by default. * * @param policy builder provider for {@link TarantoolRequestRetryPolicies.InfiniteRetryPolicy}, * e.g. a lambda function taking the builder * @param executor executor service for retry callbacks * @return this instance of builder {@link TarantoolClientConfigurator} */ SELF withRetryingIndefinitely( UnaryOperator>> policy, Executor executor); /** * Configure the infinite request retry policy. * * @param policy builder provider for {@link TarantoolRequestRetryPolicies.InfiniteRetryPolicy}, * e.g. a lambda function taking the builder * @param callback function checking whether the given exception may be retried * @param callback type for exceptions check * @return this instance of builder {@link TarantoolClientConfigurator} */ > SELF withRetryingIndefinitely( T callback, UnaryOperator> policy); /** * Configure the infinite request retry policy. * * @param policy builder provider for {@link TarantoolRequestRetryPolicies.InfiniteRetryPolicy}, * e.g. a lambda function taking the builder * @param callback function checking whether the given exception may be retried * @param executor executor service for retry callbacks * @param callback type for exceptions check * @return this instance of builder {@link TarantoolClientConfigurator} */ > SELF withRetryingIndefinitely( T callback, UnaryOperator> policy, Executor executor); /** * Specify a custom request retry policy factory. A request retry policy encapsulates an algorithm of checking * if a particular failed request needs to be repeated. The built-in request retry policies include customizable * policy variants with a bounded or unbounded number of retries. * * @param factory {@link RequestRetryPolicyFactory} * @return this instance of builder {@link TarantoolClientConfigurator} * @see TarantoolRequestRetryPolicies */ SELF withRetrying(RequestRetryPolicyFactory factory); /** * Specify a custom request retry policy factory. A request retry policy encapsulates an algorithm of checking * if a particular failed request needs to be repeated. The built-in request retry policies include customizable * policy variants with a bounded or unbounded number of retries. * * @param factory {@link RequestRetryPolicyFactory} * @param executor executor service for retry callbacks * @return this instance of builder {@link TarantoolClientConfigurator} * @see TarantoolRequestRetryPolicies */ SELF withRetrying(RequestRetryPolicyFactory factory, Executor executor); /** * Build the configured Tarantool client instance. Call this when you have specified all necessary settings. * * @return instance of tarantool tuple client {@link TarantoolClient} */ TarantoolClient> build(); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy