Skip to content

Commit

Permalink
update gen.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
jizhuozhi committed Oct 6, 2024
1 parent 348469e commit 8c71243
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 363 deletions.
7 changes: 2 additions & 5 deletions plugins/wasm-rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ sh ./scripts/gen.sh \
--name ${NAME} \
--keywords ${KEYWORDS} \
--description ${DESCRIPTION} \
--testing \
--testing-port ${PORT}
```

执行完成后将会在`plugins/wasm-rust/extensions/${NAME}`目录下生成以下文件,其中`src/lib.rs`中的内容即为插件需要实现的逻辑
Expand All @@ -22,9 +20,8 @@ sh ./scripts/gen.sh \
├── Cargo.toml
├── Makefile
├── README.md
├── docker-compose.yaml
├── envoy.yaml
├── plugin.wasm
├── README_EN.md
├── VERSION
└── src
└── lib.rs
```
Expand Down
29 changes: 0 additions & 29 deletions plugins/wasm-rust/extensions/say-hello/docker-compose.yaml

This file was deleted.

86 changes: 0 additions & 86 deletions plugins/wasm-rust/extensions/say-hello/envoy.yaml

This file was deleted.

10 changes: 3 additions & 7 deletions plugins/wasm-rust/extensions/sse-timing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ BUILD_OPTS="--release"

.DEFAULT:
build:
cargo build --target wasm32-wasi ${BUILD_OPTS}

copy: build
cargo build --target wasm32-wasi \${BUILD_OPTS}
find target -name "*.wasm" -d 3 -exec cp "{}" plugin.wasm \;

clean:
@cargo clean

docker-compose: copy
@docker-compose up
cargo clean
rm -f plugin.wasm
27 changes: 27 additions & 0 deletions plugins/wasm-rust/extensions/sse-timing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: sse耗时追踪
keywords: [sse, 性能, 耗时]
description:
---

## 功能说明

An alternative implementation of the server-timing protocol (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing),
It's useful to profile AI backend latency which uses event-stream MIME type.

## 运行属性

stage:`默认阶段`
level:`10`

### 配置说明

| Name | Type | Requirement | Default | Description |
|--------|--------|-------------|---------|-------------|
| vendor | string | false | higress | sse响应经过的代理 |

#### 配置示例

```yaml
vendor: higress
```
27 changes: 27 additions & 0 deletions plugins/wasm-rust/extensions/sse-timing/README_EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: sse-timing
keywords: [sse, performance, timing]
description:
---

## Description

An alternative implementation of the server-timing protocol (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing),
It's useful to profile AI backend latency which uses event-stream MIME type.

## Runtime

phase:`UNSPECIFIED_PHASE`
priority:`10`

## Config

| Name | Type | Requirement | Default | Description |
|--------|--------|-------------|---------|-------------------------------------------------|
| vendor | string | false | higress | the proxy vendor that sse response pass through |

## 配置示例

```yaml
vendor: higress
```
35 changes: 0 additions & 35 deletions plugins/wasm-rust/extensions/sse-timing/docker-compose.yaml

This file was deleted.

76 changes: 0 additions & 76 deletions plugins/wasm-rust/extensions/sse-timing/envoy.yaml

This file was deleted.

4 changes: 1 addition & 3 deletions plugins/wasm-rust/extensions/sse-timing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,13 @@ impl SseTiming {
// according to spec, event-stream must be utf-8 encoding
let event = from_utf8(raw_event.as_slice()).unwrap();
let modified_event = self.process_event(event.into());
self.set_http_response_body(0, modified_event.len(), modified_event.as_bytes());
modified_events.push(modified_event);
}
}
}

if !modified_events.is_empty() {
let modified_body = modified_events.concat();
self.log
.info(format!("[modified_body] {}", modified_body).as_str());
self.set_http_response_body(0, modified_body.len(), modified_body.as_bytes());
DataAction::Continue
} else {
Expand Down
Loading

0 comments on commit 8c71243

Please sign in to comment.