Skip to content

Commit

Permalink
feat: don't reuse connection when it closed (#443)
Browse files Browse the repository at this point in the history
* add benchmark

* feat: don't reuse connection when it closed
  • Loading branch information
Millione authored Aug 7, 2024
1 parent b438e65 commit ea932cf
Show file tree
Hide file tree
Showing 33 changed files with 1,336 additions and 81 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode
.idea
target
/test
/test
/benchmark/output
137 changes: 136 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [

"examples",
"examples/volo-gen",
"benchmark",
]
resolver = "2"

Expand Down Expand Up @@ -55,6 +56,7 @@ futures = "0.3"
futures-util = "0.3"
flate2 = "1"
git2 = { version = "0.19", default-features = false }
governor = "0.6"
h2 = "0.4"
heck = "0.5"
hex = "0.4"
Expand Down Expand Up @@ -106,6 +108,7 @@ simdutf8 = "0.1"
socket2 = "0.5"
sonic-rs = "0.3"
syn = "2"
sysinfo = "0.30"
tempfile = "3"
thiserror = "1"
tokio = "1"
Expand Down
39 changes: 39 additions & 0 deletions benchmark/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[package]
name = "benchmark"
version = "0.0.0"
edition.workspace = true
homepage.workspace = true
repository.workspace = true
license.workspace = true
authors.workspace = true
publish = false

[[bin]]
name = "bench-client"
path = "src/bin/client.rs"
[[bin]]
name = "bench-server"
path = "src/bin/server.rs"

[dependencies]
anyhow.workspace = true
bytes.workspace = true
chrono.workspace = true
clap = { workspace = true, features = ["derive"] }
faststr.workspace = true
governor.workspace = true
lazy_static.workspace = true
metainfo.workspace = true
motore.workspace = true
serde.workspace = true
sysinfo.workspace = true
tokio = { workspace = true, features = ["full"] }
tokio-util.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
pilota.workspace = true
volo = { path = "../volo" }
volo-thrift = { path = "../volo-thrift", features = ["multiplex"] }

[build-dependencies]
volo-build = { path = "../volo-build" }
9 changes: 9 additions & 0 deletions benchmark/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use std::path::PathBuf;

fn main() {
volo_build::Builder::thrift()
.add_service("idl/echo.thrift")
.filename(PathBuf::from("benchmark.rs"))
.write()
.unwrap()
}
46 changes: 46 additions & 0 deletions benchmark/idl/echo.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace rs echo

struct Request {
1: required string action,
2: required string msg,
}

struct Response {
1: required string action,
2: required string msg,
}

struct SubMessage {
1: optional i64 id;
2: optional string value;
}
struct Message {
1: optional i64 id;
2: optional string value;
3: optional list<SubMessage> subMessages;
}

// 复杂参数
struct ObjReq {
1: required string action(api.path = 'action')
2: required string msg(api.header = 'msg')
3: required map<string, SubMessage> msgMap(api.body = 'msgMap')
4: required list<SubMessage> subMsgs(api.body = 'subMsgs')
5: optional set<Message> msgSet(api.body = 'msgSet')
6: required Message flagMsg(api.body = 'flagMsg')
7: optional string mockCost,
}

struct ObjResp {
1: required string action(api.header = 'action')
2: required string msg(api.header = 'msg')
3: required map<string, SubMessage> msgMap(api.body = 'msgMap')
4: required list<SubMessage> subMsgs(api.body = 'subMsgs')
5: optional set<Message> msgSet(api.body = 'msgSet')
6: required Message flagMsg(api.body = 'flagMsg')
}

service EchoServer {
Response Echo(1: Request req)
ObjResp TestObj(1: ObjReq req)(api.post = '/test/obj/:action', api.baseurl = 'example.com', api.param = 'true', api.serializer = 'json')
}
Loading

0 comments on commit ea932cf

Please sign in to comment.