Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade the wasm demo developed by rust #255

Closed
zhenjunMa opened this issue Oct 14, 2021 · 1 comment · Fixed by #475
Closed

Upgrade the wasm demo developed by rust #255

zhenjunMa opened this issue Oct 14, 2021 · 1 comment · Fixed by #475
Labels
help wanted Extra attention is needed kind/enhancement New feature or request

Comments

@zhenjunMa
Copy link
Contributor

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 rust.

3. Design draft

  1. project structure
    At present, the code developed by rust is saved in: demo/faas/code/rust, but only a few core code files are saved, not a complete rust project, so you need to put the rust code into a complete rust project.

  2. 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

  3. 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. 开发者可以学习如何用rust开发WebAssembly。

三、方案概述

  1. 工程结构
    目前rust开发的代码保存在:demo/faas/code/rust,但只是保存了核心的几个代码文件,并不是一个完整的rust工程,因此需要把该目录下的rust代码放在一个完整的rust工程中然后一起提交。

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

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

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

seeflood commented Apr 7, 2022

This issue wil be assigned to @nanjingboy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants