Skip to content

Upgrade the wasm demo developed by AssemblyScript #256

@zhenjunMa

Description

@zhenjunMa

1. What would you like to be added

The old version of Layotto already supports the functions combined with WebAssembly, and provides demos implemented in three languages, golang, rust, and AssemblyScript. The new version of Layotto has refactored the support for WebAssembly and realized the expected FaaS prototype. The process of processing the request of the new version of the demo is as follows:
image

2. Why is this needed

  1. Improve Layotto + WebAssembly to realize the FaaS ecosystem.
  2. Developers can learn how to develop WebAssembly with AssemblyScript.

3. Design draft

  1. code
    Need to develop the client and server functions. The client receives the http request and calls the server. The server obtains data from redis and returns the results in turn.
    For implementation details, please refer to the golang version of the demo: demo/faas/code/golang

  2. test
    After Layotto is started, configure and load two wasm files in demo/faas/config.json, and then send request as follows:

> curl -H 'id:id_1' '127.0.0.1:2045?name=book1'
There are 100 inventories for book1.

中文

一、需要实现什么功能

旧版的Layotto已经支持了跟WebAssembly结合的的功能,并且提供了golang, rust, assemblyScript三种语言实现的demo,新版的Layotto重构了对WebAssembly的支持,实现了预期的FaaS雏形,新版demo处理请求的流程如下:

image

目前整套流程已经用Go语言实现,代码路径:demo/faas/code/golang,而rust跟assemblyScript两种demo还停留在以前的状态,因此需要进行升级。

二、做这个功能的价值

  1. 完善Layotto + WebAssembly实现FaaS的生态。
  2. 开发者可以学习如何用AssemblyScript开发WebAssembly。

三、方案概述

  1. 代码开发
    需要开发client, server两个function,client端接收http请求并调用server端,server端从redis中获取数据然后依次返回结果。
    实现细节可以参考golang版demo:demo/faas/code/golang

  2. 自测方法
    Layotto启动以后,在demo/faas/config.json中配置加载两个wasm文件,然后进行验证:

> curl -H 'id:id_1' '127.0.0.1:2045?name=book1'
There are 100 inventories for book1.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions