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

New Feature: WASM Function access cache through state API #192

Closed
zhenjunMa opened this issue Aug 23, 2021 · 1 comment
Closed

New Feature: WASM Function access cache through state API #192

zhenjunMa opened this issue Aug 23, 2021 · 1 comment
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed kind/enhancement New feature or request wasm WebAssembly technology

Comments

@zhenjunMa
Copy link
Contributor

1. What would you like to be added

A Function that truly satisfies the business requirements will inevitably rely on some basic capabilities, such as RPC, Cache, etc. The logic inside Layotto currently demonstrates how to call SayHello API through CallForeignFunction in the wasm demo provided in Layotto. Now we need to make our demo more convincing, so we need to call the State API through CallForeignFunction in the demo to access the underlying storage facilities, such as Redis.

2. Why is this needed

Make Function in the form of wasm demo more productive.

3. Design draft

A. Pass parameters

In the wasm demo of Golang, because tinyGo does not support json and pb, it uses a json format string to complete the parameter transfer. You can continue to use this method when calling the State API.

B. Biz logic

The request finally goes to the Layotto side for execution. There is already SayHello for reference, code here

C. State Components

This function requires Layotto to load storage components to handle State API calls when it starts. Therefore, component configuration needs to be added to the configuration file. You can refer to the current State demo configuration.

State API user doc

D、Extensible

About wasm demo in Layotto, in addition to golang, it also supports rust and assemblyScript. You can consider adding code to access Redis in them.

rust code
AssemblyScript code

中文

一、需要实现什么功能

一个真正满足业务诉求的Function,里面的逻辑必然会依赖一些基础能力,如RPC,Cache等,目前Layotto里面提供的wasm demo中演示了如何在Function里面通过CallForeignFunction来调用SayHello API。 现在需要让我们的demo更具有说服力,因此需要让demo里面通过CallForeignFunction调用State API,借此来访问底层存储设施,如Redis。

示例代码

二、做这个功能的价值

让wasm demo形态的Function更具备生产力。

三、方案概述

A、参数传递

在Golang的wasm demo中,由于tinyGo不支持json跟pb,因此采用的是json格式的字符串完成参数传递,在调用State API时也可以继续采用这种方式。

B、实现逻辑

请求最终走到Layotto侧来执行,目前已有SayHello可以参考,代码在这里

C、组件配置

该功能需要让Layotto启动时加载存储组件来处理State API的调用,因此需要在配置文件中增加组件配置,可以参考现在State的demo配置。

State API使用文档

D、自由扩展

Layotto里面关于wasm demo,除了golang以外,还支持了rust,assemblyScript两种,可以考虑在它们里面也增加访问Redis的代码。
rust代码
AssemblyScript代码

@zhenjunMa zhenjunMa added kind/enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Aug 23, 2021
@zhenjunMa zhenjunMa added this to To do in WASM Lab Aug 23, 2021
@zach030
Copy link
Contributor

zach030 commented Aug 27, 2021

asign to me thx

@seeflood seeflood added the wasm WebAssembly technology label Jun 4, 2022
@seeflood seeflood added this to Done in WebAssembly Lab Jun 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed kind/enhancement New feature or request wasm WebAssembly technology
Projects
Development

No branches or pull requests

3 participants