Interface CallAdapter<T>

Type Parameters:
T - the adapted return type this instance produces

public interface CallAdapter<T>
Adapts a @RestClient call's outcome into a consumer-chosen return type T, for a return-type shape RIP itself has no built-in support for (e.g. Project Reactor's Mono<T>/Flux<T>, via the separate rest-in-peace-reactor module). Registered via RIP.addCallAdapterFactory(CallAdapterFactory). See docs/design/reactor-call-adapter.md ยง5.

An adapter never dispatches its own HTTP call - adapt(java.util.concurrent.CompletableFuture<java.lang.Object>) only ever transforms the CompletableFuture RIP's own async dispatch path already produced, guaranteeing the adapted call passes through the identical pipeline (retry, cache, circuit breaker, bulkhead, interceptors) as every other RIP call, and that it is dispatched exactly once.

  • Method Summary

    Modifier and Type
    Method
    Description
    Adapts one already-in-flight call into T.
    The type to decode the HTTP response body into - what T itself wraps (e.g. for a Mono<User> adapter, this returns User.class; for Mono<RipResponse<User>>, this returns a RipResponse<User> parameterized type), the same role RipResponse's own inner-type resolution already plays for that return type.
  • Method Details

    • responseBodyType

      Type responseBodyType()
      The type to decode the HTTP response body into - what T itself wraps (e.g. for a Mono<User> adapter, this returns User.class; for Mono<RipResponse<User>>, this returns a RipResponse<User> parameterized type), the same role RipResponse's own inner-type resolution already plays for that return type.
      Returns:
      the type to decode the response body into
    • adapt

      T adapt(CompletableFuture<Object> delegate)
      Adapts one already-in-flight call into T.
      Parameters:
      delegate - the in-flight call's future - the decoded body on success (per responseBodyType()), or completed exceptionally with the same exception RIP throws for any other return type on failure (a transport failure, RestInPeaceHttpException, CircuitOpenException, BulkheadFullException)
      Returns:
      the adapted value to return from the annotated method