GH-766 Initial support to expose FunctionCatalog as actuator endpoint
This commit is contained in:
@@ -26,6 +26,10 @@
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-function-webflux</artifactId>
|
||||
</dependency>
|
||||
|
||||
@@ -23,17 +23,15 @@ import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.function.compiler.FunctionCompiler;
|
||||
import org.springframework.cloud.function.compiler.proxy.LambdaCompilingFunction;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
// @checkstyle:off
|
||||
@SpringBootApplication
|
||||
public class SampleApplication {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SpringApplication.run(SampleApplication.class, args);
|
||||
SpringApplication.run(SampleApplication.class, "--management.endpoints.web.exposure.include=functions");
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -41,6 +39,11 @@ public class SampleApplication {
|
||||
return value -> value.toUpperCase();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<Message<String>, String> uppercaseMessage() {
|
||||
return value -> value.getPayload().toUpperCase();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<Flux<String>, Flux<String>> lowercase() {
|
||||
return flux -> flux.map(value -> value.toLowerCase());
|
||||
@@ -56,28 +59,5 @@ public class SampleApplication {
|
||||
return () -> Flux.fromArray(new String[] {"foo", "bar"});
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<String, String> compiledUppercase(
|
||||
FunctionCompiler<String, String> compiler) {
|
||||
String lambda = "s -> s.toUpperCase()";
|
||||
LambdaCompilingFunction<String, String> function = new LambdaCompilingFunction<>(
|
||||
new ByteArrayResource(lambda.getBytes()), compiler);
|
||||
function.setTypeParameterizations("String", "String");
|
||||
return function;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<Flux<String>, Flux<String>> compiledLowercase(
|
||||
FunctionCompiler<Flux<String>, Flux<String>> compiler) {
|
||||
String lambda = "f->f.map(o->o.toString().toLowerCase())";
|
||||
return new LambdaCompilingFunction<>(new ByteArrayResource(lambda.getBytes()),
|
||||
compiler);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public <T, R> FunctionCompiler<T, R> compiler() {
|
||||
return new FunctionCompiler<>();
|
||||
}
|
||||
|
||||
}
|
||||
// @checkstyle:on
|
||||
|
||||
Reference in New Issue
Block a user