diff --git a/docs/RetryingTarantoolClient.md b/docs/RetryingTarantoolClient.md index ffed1804b..d33406cb8 100644 --- a/docs/RetryingTarantoolClient.md +++ b/docs/RetryingTarantoolClient.md @@ -11,38 +11,17 @@ By default, failed requests will be repeated only for some known network problem Some retry policies are available in the `TarantoolRequestRetryPolicies` class, but you may use your own implementations. If you want to use proxy calls or retry settings only for a number of requests, you may use configureClient(client) in `TarantoolClientFactory` for making a new configured client instance. Note, that the new instance will share the same -connection pool and basic client settings, and only augment the behavior of the client. -See an example below: - -```java - -TarantoolClient> setupClient() { - return TarantoolClientFactory.createClient() - .withCredentials("admin", "secret-cluster-cookie") - .withAddress(container.getRouterHost(), container.getRouterPort()) - .withProxyMethodMapping() - .build(); -} - -TarantoolClient> retrying( - TarantoolClient> client, int retries, long delay) { - return TarantoolClientFactory.configureClient(client) - .withRetryingByNumberOfAttempts( - retries, - // you can use default predicates from TarantoolRequestRetryPolicies for checking errors - TarantoolRequestRetryPolicies.retryNetworkErrors() - // also you can use your own predicates and combine them with each other or with defaults - .or(e -> e.getMessage().contains("Unsuccessful attempt")) - .or(TarantoolRequestRetryPolicies.retryTarantoolNoSuchProcedureErrors()), - policy -> policy.withDelay(delay)) - .build(); - } - -... - - TarantoolClient> client = setupClient(); - String result = retrying(client, 4, 500).callForSingleResult("retrying_function", String.class).get(); - assertEquals("Success", result); - result = retrying(client, 2, 1000).callForSingleResult("retrying_function", String.class).get(); - assertEquals("Success", result); -``` +connection pool and basic client settings, and only augment the behavior of the client. + +In this example I use custom delete function. +https://github.com/tarantool/cartridge-java/blob/25cad2843d6ed9ed76cf4020766f92307300d993/src/test/resources/cartridge/app/roles/api_router.lua#L165-L176 +You can set up any client. In this case I use CRUD client. +https://github.com/tarantool/cartridge-java/blob/25cad2843d6ed9ed76cf4020766f92307300d993/src/test/java/io/tarantool/driver/integration/ReconnectIT.java#L147-L163 +And reuse it then I need retrying client. +https://github.com/tarantool/cartridge-java/blob/25cad2843d6ed9ed76cf4020766f92307300d993/src/test/java/io/tarantool/driver/integration/ReconnectIT.java#L194-L214 +You don't have to set up basic client if you need retying client only. +All methods of client builder with prefix `withRetrying` can be used with `createClient`. + +In this code I call `delete_with_error_if_not_found` (custom delete function) before the record was inserted to the +database. So client recalls delete and removes the record after it was inserted. +https://github.com/tarantool/cartridge-java/blob/25cad2843d6ed9ed76cf4020766f92307300d993/src/test/java/io/tarantool/driver/integration/ReconnectIT.java#L82-L109