SpringCloud学习(十五)---Spring Cloud Function

湛宏旷
2023-12-01

本次系列的目标就是三轮, 第一轮知道spring官网的cloud部分都有啥,都能干啥, 第二轮是针对有用的部分做文档阅读,第三轮是横向对比.所以文档是一节节的更新的.而且这玩意主要是让我自己做笔记的.所以不接受吐槽.

Spring Cloud Function是一个具有以下高级目标的项目:

通过功能促进业务逻辑的实现。

将业务逻辑的开发生命周期与任何特定的运行时目标脱钩,以便相同的代码可以作为Web终结点,流处理器或任务运行。

支持跨无服务器提供程序的统一编程模型,以及独立运行(本地或在PaaS中)的能力。

在无服务器提供程序上启用Spring Boot功能(自动配置,依赖项注入,指标)。

它抽象出了所有传输细节和基础结构,使开发人员可以保留所有熟悉的工具和流程,并专注于业务逻辑。

Features

Spring Cloud Function features:

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

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

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

  • Transparent type conversion of inputs and outputs.

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

  • Adapters to expose function to the outside world as HTTP endpoints etc.

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

  • Compiling strings which are Java function bodies into bytecode, and then turning them into @Beans that can be wrapped as above.

  • Adapters for AWS LambdaMicrosoft AzureApache OpenWhisk and possibly other "serverless" service providers.

Here’s a complete, executable, testable Spring Boot application (implementing a simple string manipulation):

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

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

看到Flux和function我就知道我猜的八九不离十, 流式布局和函数式编程.

https://blog.csdn.net/zhulier1124/article/details/100133932

 

 

 

 

 

 类似资料: