Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
401 changes: 401 additions & 0 deletions frameworks/wtx-grpc-tls/Cargo.lock

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions frameworks/wtx-grpc-tls/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "httparena-wtx-grpc-tls"
version = "0.1.0"
edition = "2024"

[build-dependencies]
pb-rs = { default-features = false, version = "0.10" }

[dependencies]
quick-protobuf = { default-features = false, version = "0.8" }
tokio = { default-features = false, features = ["macros", "rt-multi-thread"], version = "1.0" }
wtx = { default-features = false, features = ["crypto-ring", "grpc-server", "optimizations-std", "quick-protobuf", "tokio", "getrandom"], version = "0.48" }

[profile.release]
codegen-units = 1
lto = "thin"
opt-level = 3
panic = "abort"
13 changes: 13 additions & 0 deletions frameworks/wtx-grpc-tls/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM rust:1.95 AS build
RUN rustup default nightly-2026-06-27
WORKDIR /app
COPY Cargo.toml build.rs ./
COPY proto ./proto
RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo build --release && rm -rf src/ target/release/httparena-wtx-grpc-tls* target/release/deps/httparena_wtx-grpc-tls*
COPY src ./src
RUN RUSTFLAGS="-C target-cpu=native" cargo build --release

FROM debian:bookworm-slim
COPY --from=build /app/target/release/httparena-wtx-grpc-tls /server
EXPOSE 8443
CMD ["/server"]
26 changes: 26 additions & 0 deletions frameworks/wtx-grpc-tls/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use pb_rs::{ConfigBuilder, types::FileDescriptor};
use std::{
fs::{DirBuilder, remove_dir_all},
path::Path,
};

fn main() {
let cmd = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let in_dir = Path::new(&cmd).join("proto");
let out_dir = Path::new(&std::env::var("OUT_DIR").unwrap()).join("proto");
if out_dir.exists() {
remove_dir_all(&out_dir).unwrap();
}
DirBuilder::new().create(&out_dir).unwrap();
FileDescriptor::run(
&ConfigBuilder::new(
&[Path::new(&cmd).join("proto/benchmark.proto").as_path()],
None,
Some(&out_dir.as_path()),
&[in_dir.as_path()],
)
.unwrap()
.build(),
)
.unwrap();
}
13 changes: 13 additions & 0 deletions frameworks/wtx-grpc-tls/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"display_name": "wtx",
"language": "Rust",
"type": "emerging",
"mode": "standard",
"engine": "wtx",
"description": "WTX - gRPC Server",
"repo": "https://github.com/c410-f3r/wtx",
"enabled": true,
"tests": [
"unary-grpc-tls"
]
}
15 changes: 15 additions & 0 deletions frameworks/wtx-grpc-tls/proto/benchmark.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
syntax = "proto3";
package benchmark;

service BenchmarkService {
rpc GetSum (SumRequest) returns (SumReply);
}

message SumRequest {
int32 a = 1;
int32 b = 2;
}

message SumReply {
int32 result = 1;
}
1 change: 1 addition & 0 deletions frameworks/wtx-grpc-tls/src/grpc_bindings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include!(concat!(env!("OUT_DIR"), "/proto/mod.rs"));
37 changes: 37 additions & 0 deletions frameworks/wtx-grpc-tls/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
pub mod grpc_bindings;

use grpc_bindings::benchmark::{SumReply, SumRequest};
use wtx::{
codec::format::QuickProtobuf,
grpc::{GrpcManager, GrpcMiddleware},
http::{
HttpRecvParams,
http2_server_framework::{Http2ServerFramework, HttpRouter, State, post},
},
tls::{TlsConfig, TlsModeVerified},
};

fn main() -> wtx::Result<()> {
let cert_path = wtx::misc::var("TLS_CERT").unwrap_or_else(|_| "/certs/server.crt".to_string());
let key_path = wtx::misc::var("TLS_KEY").unwrap_or_else(|_| "/certs/server.key".to_string());
let cert_file = std::fs::read_to_string(&cert_path)?.into_bytes();
let key_file = std::fs::read_to_string(&key_path)?.into_bytes();
let tls_config = TlsConfig::from_keys_pem(TlsModeVerified::new(), &cert_file, &key_file)?;
let router = HttpRouter::new(
wtx::paths!(("/benchmark.BenchmarkService/GetSum", post(endpoint_grpc_unary))),
GrpcMiddleware,
)?;
Http2ServerFramework::tokio(tls_config)?
.set_data(GrpcManager::from_drsr(QuickProtobuf))
.set_error_cb(|el| eprintln!("{el}"))
.set_http_recv_params(HttpRecvParams::with_permissive_params())
.run_in_threads("0.0.0.0:8443", router)
}

async fn endpoint_grpc_unary(state: State<'_, GrpcManager<QuickProtobuf>>) -> wtx::Result<()> {
let sr = state.data.des_from_req_bytes::<SumRequest>(&mut state.req.msg_data.body.as_slice())?;
state.req.clear();
let result = sr.a.wrapping_add(sr.b);
state.data.ser_to_res_bytes(&mut state.req.msg_data.body, SumReply { result })?;
Ok(())
}
8 changes: 8 additions & 0 deletions site/data/frameworks.json
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,14 @@
"engine": "wtx",
"mode": "standard",
"variants": [
{
"dir": "wtx-grpc-tls",
"description": "WTX - gRPC Server",
"repo": "https://github.com/c410-f3r/wtx",
"type": "emerging",
"engine": "wtx",
"mode": "standard"
},
{
"dir": "wtx-http2",
"description": "WTX - HTTP/2 Framework Server",
Expand Down
38 changes: 38 additions & 0 deletions site/data/results/wtx.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,44 @@
"status_3xx": 0,
"status_4xx": 0,
"status_5xx": 0
},
"unary-grpc-tls-1024": {
"framework": "wtx",
"language": "Rust",
"rps": 2371712,
"avg_latency": "39.56ms",
"p99_latency": "1.17s",
"cpu": "6417.3%",
"memory": "904MiB",
"connections": 1024,
"threads": 64,
"duration": "5s",
"pipeline": 1,
"bandwidth": "103.02MB/s",
"reconnects": 0,
"status_2xx": 12000866,
"status_3xx": 0,
"status_4xx": 0,
"status_5xx": 0
},
"unary-grpc-tls-256": {
"framework": "wtx",
"language": "Rust",
"rps": 2409735,
"avg_latency": "10.27ms",
"p99_latency": "328.46ms",
"cpu": "6207.2%",
"memory": "542MiB",
"connections": 256,
"threads": 64,
"duration": "5s",
"pipeline": 1,
"bandwidth": "104.25MB/s",
"reconnects": 0,
"status_2xx": 12145065,
"status_3xx": 0,
"status_4xx": 0,
"status_5xx": 0
}
}
}
Loading