Added initial support for lazy style FunctionCatalog/Registry which:
- does not rely on any of the existing wrappers and instead relies on internal wrapper which performs in-flight/just-in-time wrapping and unwrapping from reactive to imperative types - performs transparent type conversion relying on MessageConverters and ConversionService - supports multiple inputs/outputs
This commit is contained in:
@@ -40,6 +40,7 @@ import reactor.core.publisher.Mono;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.cloud.function.context.FunctionCatalog;
|
||||
import org.springframework.cloud.function.context.catalog.FunctionInspector;
|
||||
import org.springframework.cloud.function.context.catalog.LazyFunctionRegistry.FunctionInvocationWrapper;
|
||||
import org.springframework.cloud.function.context.config.RoutingFunction;
|
||||
import org.springframework.cloud.function.context.message.MessageUtils;
|
||||
import org.springframework.cloud.function.core.FluxConsumer;
|
||||
@@ -240,8 +241,31 @@ public class RequestProcessor {
|
||||
else if (function instanceof FluxedConsumer || function instanceof FluxConsumer) {
|
||||
((Mono<?>) function.apply(flux)).subscribe();
|
||||
logger.debug("Handled POST with consumer");
|
||||
responseEntityMono = Mono
|
||||
.just(ResponseEntity.status(HttpStatus.ACCEPTED).build());
|
||||
responseEntityMono = Mono.just(ResponseEntity.status(HttpStatus.ACCEPTED).build());
|
||||
}
|
||||
else if (function instanceof FunctionInvocationWrapper) {
|
||||
Object targetFunction = ((FunctionInvocationWrapper) function).getTarget();
|
||||
Publisher<?> result = (Publisher<?>) function.apply(flux);
|
||||
if (targetFunction instanceof Consumer) {
|
||||
if (result != null) {
|
||||
((Mono) result).subscribe();
|
||||
}
|
||||
logger.debug("Handled POST with consumer");
|
||||
responseEntityMono = Mono
|
||||
.just(ResponseEntity.status(HttpStatus.ACCEPTED).build());
|
||||
}
|
||||
else {
|
||||
result = Flux.from((Publisher) result);
|
||||
logger.debug("Handled POST with function");
|
||||
if (stream) {
|
||||
responseEntityMono = stream(wrapper, result);
|
||||
}
|
||||
else {
|
||||
|
||||
responseEntityMono = response(wrapper, getTargetIfRouting(wrapper, ((FunctionInvocationWrapper) function).getTarget()), result,
|
||||
body == null ? null : !(body instanceof Collection), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Flux<?> result = Flux.from((Publisher) function.apply(flux));
|
||||
|
||||
Reference in New Issue
Block a user