SpringCloud學習(十五)---Spring Cloud Function

habazhu1110發表於2020-11-17

本次系列的目標就是三輪, 第一輪知道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

 

 

 

 

 

相關文章