Skip to content

Commit ea932cf

Browse files
authored
feat: don't reuse connection when it closed (#443)
* add benchmark * feat: don't reuse connection when it closed
1 parent b438e65 commit ea932cf

33 files changed

+1336
-81
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.vscode
22
.idea
33
target
4-
/test
4+
/test
5+
/benchmark/output

Cargo.lock

+136-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ members = [
1010

1111
"examples",
1212
"examples/volo-gen",
13+
"benchmark",
1314
]
1415
resolver = "2"
1516

@@ -55,6 +56,7 @@ futures = "0.3"
5556
futures-util = "0.3"
5657
flate2 = "1"
5758
git2 = { version = "0.19", default-features = false }
59+
governor = "0.6"
5860
h2 = "0.4"
5961
heck = "0.5"
6062
hex = "0.4"
@@ -106,6 +108,7 @@ simdutf8 = "0.1"
106108
socket2 = "0.5"
107109
sonic-rs = "0.3"
108110
syn = "2"
111+
sysinfo = "0.30"
109112
tempfile = "3"
110113
thiserror = "1"
111114
tokio = "1"

benchmark/Cargo.toml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[package]
2+
name = "benchmark"
3+
version = "0.0.0"
4+
edition.workspace = true
5+
homepage.workspace = true
6+
repository.workspace = true
7+
license.workspace = true
8+
authors.workspace = true
9+
publish = false
10+
11+
[[bin]]
12+
name = "bench-client"
13+
path = "src/bin/client.rs"
14+
[[bin]]
15+
name = "bench-server"
16+
path = "src/bin/server.rs"
17+
18+
[dependencies]
19+
anyhow.workspace = true
20+
bytes.workspace = true
21+
chrono.workspace = true
22+
clap = { workspace = true, features = ["derive"] }
23+
faststr.workspace = true
24+
governor.workspace = true
25+
lazy_static.workspace = true
26+
metainfo.workspace = true
27+
motore.workspace = true
28+
serde.workspace = true
29+
sysinfo.workspace = true
30+
tokio = { workspace = true, features = ["full"] }
31+
tokio-util.workspace = true
32+
tracing.workspace = true
33+
tracing-subscriber.workspace = true
34+
pilota.workspace = true
35+
volo = { path = "../volo" }
36+
volo-thrift = { path = "../volo-thrift", features = ["multiplex"] }
37+
38+
[build-dependencies]
39+
volo-build = { path = "../volo-build" }

benchmark/build.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use std::path::PathBuf;
2+
3+
fn main() {
4+
volo_build::Builder::thrift()
5+
.add_service("idl/echo.thrift")
6+
.filename(PathBuf::from("benchmark.rs"))
7+
.write()
8+
.unwrap()
9+
}

benchmark/idl/echo.thrift

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
namespace rs echo
2+
3+
struct Request {
4+
1: required string action,
5+
2: required string msg,
6+
}
7+
8+
struct Response {
9+
1: required string action,
10+
2: required string msg,
11+
}
12+
13+
struct SubMessage {
14+
1: optional i64 id;
15+
2: optional string value;
16+
}
17+
struct Message {
18+
1: optional i64 id;
19+
2: optional string value;
20+
3: optional list<SubMessage> subMessages;
21+
}
22+
23+
// 复杂参数
24+
struct ObjReq {
25+
1: required string action(api.path = 'action')
26+
2: required string msg(api.header = 'msg')
27+
3: required map<string, SubMessage> msgMap(api.body = 'msgMap')
28+
4: required list<SubMessage> subMsgs(api.body = 'subMsgs')
29+
5: optional set<Message> msgSet(api.body = 'msgSet')
30+
6: required Message flagMsg(api.body = 'flagMsg')
31+
7: optional string mockCost,
32+
}
33+
34+
struct ObjResp {
35+
1: required string action(api.header = 'action')
36+
2: required string msg(api.header = 'msg')
37+
3: required map<string, SubMessage> msgMap(api.body = 'msgMap')
38+
4: required list<SubMessage> subMsgs(api.body = 'subMsgs')
39+
5: optional set<Message> msgSet(api.body = 'msgSet')
40+
6: required Message flagMsg(api.body = 'flagMsg')
41+
}
42+
43+
service EchoServer {
44+
Response Echo(1: Request req)
45+
ObjResp TestObj(1: ObjReq req)(api.post = '/test/obj/:action', api.baseurl = 'example.com', api.param = 'true', api.serializer = 'json')
46+
}

0 commit comments

Comments
 (0)