Skip to content

Commit 8086e37

Browse files
authored
Merge branch 'main' into ai-sec-update
2 parents 482606f + e7561c3 commit 8086e37

File tree

13 files changed

+885
-6
lines changed

13 files changed

+885
-6
lines changed

plugins/wasm-rust/Makefile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ IMAGE_TAG = $(if $(strip $(PLUGIN_VERSION)),${PLUGIN_VERSION},${BUILD_TIME}-${CO
66
IMG ?= ${REGISTRY}${PLUGIN_NAME}:${IMAGE_TAG}
77

88
.DEFAULT:
9-
lint-base:
10-
cargo fmt --all --check
11-
cargo clippy --workspace --all-features --all-targets
12-
lint:
13-
cargo fmt --all --check --manifest-path extensions/${PLUGIN_NAME}/Cargo.toml
14-
cargo clippy --workspace --all-features --all-targets --manifest-path extensions/${PLUGIN_NAME}/Cargo.toml
159
build:
1610
DOCKER_BUILDKIT=1 docker build \
1711
--build-arg PLUGIN_NAME=${PLUGIN_NAME} \
@@ -20,3 +14,10 @@ build:
2014
.
2115
@echo ""
2216
@echo "output wasm file: extensions/${PLUGIN_NAME}/plugin.wasm"
17+
18+
lint-base:
19+
cargo fmt --all --check
20+
cargo clippy --workspace --all-features --all-targets
21+
lint:
22+
cargo fmt --all --check --manifest-path extensions/${PLUGIN_NAME}/Cargo.toml
23+
cargo clippy --workspace --all-features --all-targets --manifest-path extensions/${PLUGIN_NAME}/Cargo.toml

plugins/wasm-rust/example/sse-timing/Cargo.lock

Lines changed: 270 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "sse-timing"
3+
version = "0.1.0"
4+
edition = "2021"
5+
publish = false
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
[lib]
9+
crate-type = ["cdylib"]
10+
11+
[dependencies]
12+
higress-wasm-rust = { path = "../../", version = "0.1.0" }
13+
proxy-wasm = { git="https://github.com/higress-group/proxy-wasm-rust-sdk", branch="main", version="0.2.2" }
14+
serde = { version = "1.0", features = ["derive"] }
15+
serde_json = "1.0"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
BUILD_OPTS="--release"
2+
3+
.DEFAULT:
4+
build:
5+
cargo build --target wasm32-wasi ${BUILD_OPTS}
6+
find target -name "*.wasm" -d 3 -exec cp "{}" plugin.wasm \;
7+
8+
clean:
9+
cargo clean
10+
rm -f plugin.wasm
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Proxy-Wasm plugin example: SSE Timing
2+
3+
Proxy-Wasm plugin that traces Server-Side Event(SSE) duration from request start.
4+
5+
### Building
6+
7+
```sh
8+
$ make
9+
```
10+
11+
### Using in Envoy
12+
13+
This example can be run with [`docker compose`](https://docs.docker.com/compose/install/)
14+
and has a matching Envoy configuration.
15+
16+
```sh
17+
$ docker compose up
18+
```
19+
20+
#### Access granted.
21+
22+
Send HTTP request to `localhost:10000/`:
23+
24+
```sh
25+
$ curl localhost:10000/
26+
```
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright (c) 2023 Alibaba Group Holding Ltd.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
services:
16+
envoy:
17+
image: higress-registry.cn-hangzhou.cr.aliyuncs.com/higress/all-in-one:latest
18+
entrypoint: /usr/local/bin/envoy
19+
command: -c /etc/envoy/envoy.yaml --component-log-level wasm:debug
20+
depends_on:
21+
- sse-server
22+
hostname: envoy
23+
ports:
24+
- "10000:10000"
25+
volumes:
26+
- ./envoy.yaml:/etc/envoy/envoy.yaml
27+
- ./target/wasm32-wasi/release:/etc/envoy/proxy-wasm-plugins
28+
networks:
29+
- envoymesh
30+
sse-server:
31+
build: sse-server
32+
networks:
33+
- envoymesh
34+
networks:
35+
envoymesh: {}

0 commit comments

Comments
 (0)