Package com.commercetools.api.client
Interface RetryHandler<TResult>
- Type Parameters:
TResult
- type of the resultServiceRegion region = System.getenv("CTP_REGION") == null ? ServiceRegion.GCP_EUROPE_WEST1 : ServiceRegion.valueOf(System.getenv("CTP_REGION")); String authURL = System.getenv("CTP_AUTH_URL") == null ? region.getOAuthTokenUrl() : System.getenv("CTP_AUTH_URL"); String apiUrl = System.getenv("CTP_API_URL") == null ? region.getApiUrl() : System.getenv("CTP_API_URL"); final ProjectApiRoot projectApiRoot = ApiRootBuilder.of() .defaultClient(ClientCredentials.of() .withClientId(CommercetoolsTestUtils.getClientId()) .withClientSecret(CommercetoolsTestUtils.getClientSecret()) .build(), authURL, apiUrl) .withErrorMiddleware(ErrorMiddleware.ExceptionMode.UNWRAP_COMPLETION_EXCEPTION) .build(CommercetoolsTestUtils.getProjectKey()); CartsFixtures.withUpdateableCart(cart -> { final ApiHttpResponse<Cart> deCart = projectApiRoot.carts() .withId(cart.getId()) .post(CartUpdateBuilder.of() .version(cart.getVersion()) .actions(CartSetCountryActionBuilder.of().country("DE").build()) .build()) .executeBlocking(); final Cart modCart = RetryHandler .concurrentModification(projectApiRoot.carts() .withId(cart.getId()) .post(CartUpdateBuilder.of() .version(cart.getVersion()) .actions(CartSetCountryActionBuilder.of().country("DE").build()) .build()), CartUpdate::builder, CartUpdateBuilder::version) .executeBlocking() .getBody(); return modCart; });
See the test code.
public interface RetryHandler<TResult>
Handler functions to retry single requests.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends ApiDeleteMethod<T,
TResult>, TResult>
RequestCommand<TResult>concurrentModification
(T request) static <T extends BodyApiMethod<T,
TResult, TBody>, TResult, TBody extends ResourceUpdate<TBody, ?, TBuilder>, TBuilder extends Builder<TBody>>
RequestCommand<TResult>concurrentModification
(T request, Function<TBody, TBuilder> builderCopyFn, BiFunction<TBuilder, Long, TBuilder> updateFn) execute()
-
Method Details
-
execute
CompletableFuture<ApiHttpResponse<TResult>> execute() -
concurrentModification
static <T extends BodyApiMethod<T,TResult, RequestCommand<TResult> concurrentModificationTBody>, TResult, TBody extends ResourceUpdate<TBody, ?, TBuilder>, TBuilder extends Builder<TBody>> (T request, Function<TBody, TBuilder> builderCopyFn, BiFunction<TBuilder, Long, TBuilder> updateFn) -
concurrentModification
static <T extends ApiDeleteMethod<T,TResult>, RequestCommand<TResult> concurrentModificationTResult> (T request)
-