Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update wtx to version 0.19.0 #474

Closed
wants to merge 1 commit into from
Closed
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
109 changes: 41 additions & 68 deletions rust_wtx_bench/Cargo.lock

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

2 changes: 1 addition & 1 deletion rust_wtx_bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ path = "src/main.rs"
[dependencies]
quick-protobuf = { default-features = false, version = "0.8" }
tokio = { default-features = false, features = ["parking_lot", "rt-multi-thread"], version = "1.0" }
wtx = { default-features = false, features = ["grpc", "optimization", "quick-protobuf"], version = "0.17" }
wtx = { default-features = false, features = ["grpc", "optimization", "quick-protobuf"], version = "0.19" }

[build-dependencies]
pb-rs = { default-features = false, version = "0.10" }
Expand Down
27 changes: 13 additions & 14 deletions rust_wtx_bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,33 @@ pub mod grpc_bindings;

use wtx::{
data_transformation::dnsn::QuickProtobuf,
grpc::{GrpcStatusCode, Server, ServerData},
grpc::{GrpcManager, GrpcStatusCode},
http::{
server_framework::{post, Router},
ReqResBuffer, Request, StatusCode,
server_framework::{post, Router, ServerFrameworkBuilder, State},
ReqResBuffer, StatusCode,
},
};

fn main() -> wtx::Result<()> {
let cpus = std::env::var("GRPC_SERVER_CPUS")
.ok()
.and_then(|var| var.parse().ok())
.unwrap_or(1);
tokio::runtime::Builder::new_multi_thread()
.worker_threads(cpus)
.worker_threads(std::env::var("GRPC_SERVER_CPUS")?.parse()?)
.enable_all()
.build()?
.block_on(async move {
let router = Router::paths(wtx::paths!((
"/helloworld.Greeter/SayHello",
post(say_hello)
),));
Server::new(router).listen("0.0.0.0:50051", |_| {}).await
)))?;
ServerFrameworkBuilder::new(router)
.with_req_aux(|| QuickProtobuf::default())
.listen("0.0.0.0:50051", |_| {})
.await
})
}

async fn say_hello(
_: &mut Request<ReqResBuffer>,
_: ServerData<QuickProtobuf>,
) -> wtx::Result<(StatusCode, GrpcStatusCode)> {
Ok((StatusCode::Ok, GrpcStatusCode::Ok))
state: State<'_, (), GrpcManager<QuickProtobuf>, ReqResBuffer>,
) -> wtx::Result<StatusCode> {
*state.ra.status_code_mut() = GrpcStatusCode::Ok;
Ok(StatusCode::Ok)
}
Loading