Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update the api for wasm functions; 设计 FaaS 编程 API #611

@zhenjunMa

Description

@zhenjunMa

1. Background

At present, the API that Layotto interacts with wasm functions is a set of specifications defined by proxy-wasm. The official description of the project is shown in the following figure:

image

The project itself designed for network proxies, such as envoy, and the goal is to support extending the functionality of envoy through wasm.

If a function developed based on this API wants to receive an http request, it needs to implement the following three interfaces:

  1. OnHttpRequestHeaders
  2. OnHttpRequestBody
  3. OnHttpRequestTrailers

This obviously does not meet the "simple" principle.

2. What we need to do

Maybe we can redefine a set of ABIs suitable for functions. The development form can refer to proxy-wasm. For example, create a new repository function-wasm to save the definition, and then use function-wasm-xx to save the specific implementation.

For the definition of function interfaces, please refer to:

  1. Ali Cloud:https://help.aliyun.com/document_detail/74757.html
  2. AWS:https://docs.aws.amazon.com/lambda/latest/dg/java-handler.html
  3. Google:https://cloud.google.com/functions/docs/functions-framework

It is not easy to define a set of APIs suitable for functions, but we do not need to be perfect at one time. What is more important is to start simple and follow the basic principle of "making functions simple enough for users".

中文

一、背景

目前 Layotto 跟 wasm 函数交互的 API 是使用 proxy-wasm 定义的一套规范,该项目的官方描述如下图所示:

image

它本身是面向网络代理设计的,目标是支持通过 wasm 扩展 envoy 的功能。

基于这套 API 开发的函数,如果想要接收一个 http request, 它需要实现如下三个接口:

  1. OnHttpRequestHeaders
  2. OnHttpRequestBody
  3. OnHttpRequestTrailers

这显然不符合“简单”的原则。

二、需要做什么

或许我们可以重新定义一套适用于函数的 ABI,开发形式可以参考 proxy-wasm, 比如新建一个仓库 function-wasm 来保存定义,然后通过 function-wasm-xx 来保存具体实现。

具体接口的定义可以参考:

  1. 阿里云文档:https://help.aliyun.com/document_detail/74757.html
  2. AWS文档:https://docs.aws.amazon.com/lambda/latest/dg/java-handler.html
  3. Google文档:https://cloud.google.com/functions/docs/functions-framework

想要定义一套适用于函数的 API 本身并不容易,但我们不需要大而全,更重要的是从简单开始,遵守函数场景下的基本原则"让用户开发函数足够简单"。

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions