Remove function composition from the catalog interface

Should be easy enoug hto add back later, but it was causing issues
with type conversion where we are npot yet sophisticated enough
to chain functions together and keep track of the types being
passed between them.
This commit is contained in:
Dave Syer
2017-01-10 12:31:12 -05:00
parent d669a544b9
commit 9321dc7311
9 changed files with 9 additions and 59 deletions

View File

@@ -51,17 +51,6 @@ public abstract class AbstractFunctionRegistry implements FunctionRegistry {
private final SimpleClassLoader classLoader = new SimpleClassLoader(AbstractFunctionRegistry.class.getClassLoader());
@Override
@SuppressWarnings("unchecked")
public <T, R> Function<T, R> composeFunction(String... functionNames) {
@SuppressWarnings("rawtypes")
Function function = this.lookupFunction(functionNames[0]);
for (int i = 1; i < functionNames.length; i++) {
function = function.andThen(this.lookupFunction(functionNames[i]));
}
return function;
}
@Override
public <T> Consumer<T> lookupConsumer(String name) {
@SuppressWarnings("unchecked")

View File

@@ -29,7 +29,5 @@ public interface FunctionCatalog {
<T, R> Function<T, R> lookupFunction(String name);
<T, R> Function<T, R> composeFunction(String... functionNames);
<T> Supplier<T> lookupSupplier(String name);
}

View File

@@ -16,8 +16,6 @@
package org.springframework.cloud.function.registry;
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.io.IOException;
import java.util.List;
@@ -26,6 +24,8 @@ import java.util.function.Function;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import reactor.core.publisher.Flux;
/**
@@ -53,15 +53,4 @@ public class FileSystemFunctionRegistryTests {
assertEquals("BAR", results.get(1));
}
@Test
public void composeFunction() throws IOException {
FileSystemFunctionRegistry registry = new FileSystemFunctionRegistry(this.directory);
registry.registerFunction("uppercase", "f->f.map(s->s.toString().toUpperCase())");
registry.registerFunction("exclaim", "f->f.map(s->s+\"!!!\")");
Function<Flux<String>, Flux<String>> function = registry.composeFunction("uppercase", "exclaim");
Flux<String> output = function.apply(Flux.just("foo", "bar"));
List<String> results = output.collectList().block();
assertEquals("FOO!!!", results.get(0));
assertEquals("BAR!!!", results.get(1));
}
}