This version is still in development and is not considered stable yet. For the latest stable version, please use spring-cloud-function 4.1.4!spring-doc.cn

Introduction

Spring Cloud Function is a project with the following high-level goals:spring-doc.cn

  • Promote the implementation of business logic via functions.spring-doc.cn

  • Decouple the development lifecycle of business logic from any specific runtime target so that the same code can run as a web endpoint, a stream processor, or a task.spring-doc.cn

  • Support a uniform programming model across serverless providers, as well as the ability to run standalone (locally or in a PaaS).spring-doc.cn

  • Enable Spring Boot features (auto-configuration, dependency injection, metrics) on serverless providers.spring-doc.cn

It abstracts away all of the transport details and infrastructure, allowing the developer to keep all the familiar tools and processes, and focus firmly on business logic.spring-doc.cn

Here’s a complete, executable, testable Spring Boot application (implementing a simple string manipulation):spring-doc.cn

@SpringBootApplication
public class Application {

  @Bean
  public Function<String, String> uppercase() {
    return value -> value.toUpperCase();
  }

  public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
  }
}

It’s just a Spring Boot application, so it can be built, run and tested, locally and in a CI build, the same way as any other Spring Boot application. The Function is from java.util and Flux is a Reactive Streams Publisher from Project Reactor. The function can be accessed over HTTP or messaging.spring-doc.cn

Spring Cloud Function has the following features:spring-doc.cn

  • Choice of programming styles - reactive, imperative or hybrid.spring-doc.cn

  • Function composition and adaptation (e.g., composing imperative functions with reactive).spring-doc.cn

  • Support for reactive function with multiple inputs and outputs allowing merging, joining and other complex streaming operation to be handled by functions.spring-doc.cn

  • Transparent type conversion of inputs and outputs.spring-doc.cn

  • Packaging functions for deployments, specific to the target platform (e.g., Project Riff, AWS Lambda and more)spring-doc.cn

  • Adapters to expose function to the outside world as HTTP endpoints etc.spring-doc.cn

  • Deploying a JAR file containing such an application context with an isolated classloader, so that you can pack them together in a single JVM.spring-doc.cn

  • Adapters for AWS Lambda, Azure, Google Cloud Functions, and possibly other "serverless" service providers.spring-doc.cn