Fix docs with regard to Flux.interval
Also provide ability to run with `Flux.interval(Duration)` in compiled scripts Fixes gh-174
This commit is contained in:
@@ -53,6 +53,7 @@ public abstract class AbstractFunctionCompiler<F> {
|
||||
private static String SOURCE_CODE_TEMPLATE = "package "
|
||||
+ AbstractFunctionCompiler.class.getPackage().getName() + ";\n"
|
||||
+ "import java.util.*;\n" // Helpful to include this
|
||||
+ "import java.time.*;\n" // Helpful to include this
|
||||
+ "import java.util.function.*;\n"
|
||||
+ "import reactor.core.publisher.Flux;\n"
|
||||
+ "public class %s implements CompilationResultFactory<%s> {\n"
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.cloud.function.compiler;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.cloud.function.core.FunctionFactoryUtils;
|
||||
|
||||
@@ -47,4 +48,13 @@ public class SupplierCompilerTests {
|
||||
assertThat(compiled.getResult().get()).isEqualTo("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void supppliesFluxStreamString() {
|
||||
CompiledFunctionFactory<Supplier<Flux<String>>> compiled = new SupplierCompiler<Flux<String>>(
|
||||
String.class.getName()).compile("foos",
|
||||
"() -> Flux.interval(Duration.ofMillis(1000)).map(Object::toString)",
|
||||
"Flux<String>");
|
||||
assertThat(FunctionFactoryUtils.isFluxSupplier(compiled.getFactoryMethod())).isTrue();
|
||||
assertThat(compiled.getResult().get().blockFirst()).isEqualTo("0");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user