加入CODE CHINA

· 不限速    · 不限空间    · 不限人数    · 私仓免费

免费加入
README.md

中文文档点击这里


Rust and WebAssembly Function as a Service (FaaS) on Tencent Cloud

Prerequisites

If you have not done so already, follow these simple instructions to install ssvmup on your development computer.

Build the WASM bytecode

We build a Rust function as a service. It simply takes the function input from STDIN and outputs the results into STDOUT. That allows it to be used in a variety of different scenarions and payloads. The function anticipates an input JSON string with key1 and key2 fields. As we will see that is the JSON format used in TencentCloud's built-in hello world tests.

To build the Rust function into a WebAssembly bytecode application, do the following from your command line. It might take a few minutes to build.

$ ssvmup build

Package for deployment

$ cp pkg/hello_bg.wasm cloud/
$ cd cloud
$ zip hello.zip *

Deploy on TencentCloud

0 Go to the console https://cloud.tencent.com/?lang=en

1 Go to Products | Serverless Cloud Function | Function Service | Create

2 For Create Method, select CustomRuntime from the dropdown list

3 Select the Empty function template

4 Click on Next

Deploy step 1

5 Set the Execution handler to hello_bg.wasm

6 Select "Local zip file" for Submitting Method, and then upload the hello.zip file

7 Click on Complete

Deploy step 2

Test

Once the function is successfully deployed, go to the Function code tab.

Deploy success

Scroll down and click on the Test button. The function will take the hello world JSON data input

{
  "key1": "test value 1",
  "key2": "test value 2"
}

Test the function

and output a hello message.

Hello! test value 1, test value 2

Test execution result

That's it! You have now tested and deployed your first server-side WebAssembly function!

Next step

The next step is to create a complete demo to run and visualize a machine learning algorithm.

项目简介

当前项目暂无项目简介

发行版本

当前项目没有发行版本

贡献者 3

M Michael Yuan @Michael Yuan
M MileyFu @MileyFu
M Michael Yuan @Michael Yuan

开发语言

  • Shell 64.5 %
  • Rust 35.5 %