* Fix typos in docs

* Add `spring-cloud-function-integration` into `spring-cloud-function-dependencies`
* Fix "memoize" logic in the `FunctionLookupHelper` and cover it in the `FunctionFlowTests`
against `@SpyBean FunctionCatalog`
This commit is contained in:
abilan
2023-05-17 13:59:52 -04:00
committed by Oleg Zhurakousky
parent e0629b5080
commit 42a5319c99
4 changed files with 46 additions and 25 deletions

View File

@@ -40,24 +40,22 @@ public class FunctionLookupHelper {
}
<P> Supplier<P> lookupSupplier(String functionDefinition) {
return () ->
memoize(() -> this.functionCatalog.<Supplier<P>>lookup(Supplier.class, functionDefinition))
.get()
.get();
Supplier<Supplier<P>> memoizedSupplier = lazyLookup(Supplier.class, functionDefinition);
return () -> memoizedSupplier.get().get();
}
<P> Function<P, ?> lookupFunction(String functionDefinition) {
return (p) ->
memoize(() -> this.functionCatalog.<Function<P, ?>>lookup(Function.class, functionDefinition))
.get()
.apply(p);
Supplier<Function<P, ?>> memoizedFunction = lazyLookup(Function.class, functionDefinition);
return (p) -> memoizedFunction.get().apply(p);
}
<P> Consumer<P> lookupConsumer(String consumerDefinition) {
return (p) ->
memoize(() -> this.functionCatalog.<Consumer<P>>lookup(Consumer.class, consumerDefinition))
.get()
.accept(p);
Supplier<Consumer<P>> memoizedConsumer = lazyLookup(Consumer.class, consumerDefinition);
return (p) -> memoizedConsumer.get().accept(p);
}
private <T> Supplier<T> lazyLookup(Class<?> functionType, String functionDefinition) {
return memoize(() -> this.functionCatalog.lookup(functionType, functionDefinition));
}
/**