forked from alibaba/higress
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add wasm-rust sdk with say-hello simple extension (alibaba#350)
- Loading branch information
Showing
17 changed files
with
1,332 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ bazel-testlogs | |
bazel-wasm-cpp | ||
tools/bin/ | ||
helm/**/charts/**.tgz | ||
target/ | ||
tools/hack/cluster.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "higress-wasm-rust" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
proxy-wasm = "0.2.1" | ||
serde = "1.0" | ||
serde_json = "1.0" | ||
uuid = { version = "1.3.3", features = ["v4"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM rust:1.69 as builder | ||
WORKDIR /workspace | ||
RUN rustup target add wasm32-wasi | ||
ARG PLUGIN_NAME="say-hello" | ||
ARG BUILD_OPTS="--release" | ||
COPY . . | ||
WORKDIR /workspace/extensions/$PLUGIN_NAME | ||
RUN cargo build --target wasm32-wasi $BUILD_OPTS \ | ||
&& cp target/wasm32-wasi/release/*.wasm /main.wasm | ||
|
||
FROM scratch | ||
COPY --from=builder /main.wasm plugin.wasm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
PLUGIN_NAME ?= say-hello | ||
REGISTRY ?= higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/ | ||
BUILD_TIME := $(shell date "+%Y%m%d-%H%M%S") | ||
COMMIT_ID := $(shell git rev-parse --short HEAD 2>/dev/null) | ||
IMAGE_TAG = $(if $(strip $(PLUGIN_VERSION)),${PLUGIN_VERSION},${BUILD_TIME}-${COMMIT_ID}) | ||
IMG ?= ${REGISTRY}${PLUGIN_NAME}:${IMAGE_TAG} | ||
|
||
.DEFAULT: | ||
build: | ||
DOCKER_BUILDKIT=1 docker build \ | ||
--build-arg PLUGIN_NAME=${PLUGIN_NAME} \ | ||
-t ${IMG} \ | ||
--output extensions/${PLUGIN_NAME} \ | ||
. | ||
@echo "" | ||
@echo "output wasm file: extensions/${PLUGIN_NAME}/plugin.wasm" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 介绍 | ||
|
||
此 SDK 用于使用 Rust 语言开发 Higress 的 Wasm 插件。 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "say-hello" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
higress-wasm-rust = { path = "../../", version = "0.1.0" } | ||
proxy-wasm = "0.2.1" | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_json = "1.0" |
Oops, something went wrong.