Package com.shri.restinpeace
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 TypeMethodDescriptionadapt(CompletableFuture<Object> delegate) Adapts one already-in-flight call intoT.The type to decode the HTTP response body into - whatTitself wraps (e.g. for aMono<User>adapter, this returnsUser.class; forMono<RipResponse<User>>, this returns aRipResponse<User>parameterized type), the same roleRipResponse'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 - whatTitself wraps (e.g. for aMono<User>adapter, this returnsUser.class; forMono<RipResponse<User>>, this returns aRipResponse<User>parameterized type), the same roleRipResponse's own inner-type resolution already plays for that return type.- Returns:
- the type to decode the response body into
-
adapt
Adapts one already-in-flight call intoT.- Parameters:
delegate- the in-flight call's future - the decoded body on success (perresponseBodyType()), 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
-