Skip to main content

Posts

Showing posts from April, 2018

Sneak peek at spring-cloud-function serverless project

Almost a year ago Spring team announced spring-cloud-function umbrella project. It's basically a Spring's approach to serverless (I prefer the term function-as-a-service) programming. Function<T, R> becomes the smallest building block in a Spring application. Functions defined as Spring beans are automatically exposed e.g. via HTTP in RPC style. Just a quick example how it looks:

@SpringBootApplication public class FaasApplication { public static void main(String[] args) throws Exception { SpringApplication.run(FaasApplication.class, args); } @Bean Function<Long, Person> personById(PersonRepository repo) { return repo::findById; } } @Component interface PersonRepository { Person findById(long id); Mono<Person> findByIdAsync(long id); } The implementation of PersonRepository is irrelevant here. This is a valid Spring Boot application. But once you put spring-cloud-function dependency, beans of Function type come …