bla
This commit is contained in:
parent
e857d7c8dc
commit
b35dc2dfba
65
Cargo.lock
generated
65
Cargo.lock
generated
@ -169,6 +169,26 @@ version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
||||
|
||||
[[package]]
|
||||
name = "dashmap"
|
||||
version = "6.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
"hashbrown 0.14.5",
|
||||
"lock_api",
|
||||
"once_cell",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.13.0"
|
||||
@ -302,6 +322,12 @@ version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.2"
|
||||
@ -460,6 +486,16 @@ version = "0.4.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.25"
|
||||
@ -525,6 +561,19 @@ version = "1.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.3.1"
|
||||
@ -692,6 +741,15 @@ dependencies = [
|
||||
"getrandom 0.2.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.11.1"
|
||||
@ -726,6 +784,7 @@ name = "rust_test_grpc"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-stream",
|
||||
"dashmap",
|
||||
"prost",
|
||||
"prost-types",
|
||||
"serde",
|
||||
@ -767,6 +826,12 @@ version = "1.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd"
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.217"
|
||||
|
@ -13,6 +13,7 @@ path = "src/client.rs"
|
||||
|
||||
[dependencies]
|
||||
async-stream = "0.3.6"
|
||||
dashmap = "6.1.0"
|
||||
prost = "0.13"
|
||||
prost-types = "0.13"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
@ -14,10 +14,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Ok(req)
|
||||
});
|
||||
|
||||
let request =
|
||||
Request::new(SomeRequest { what_client_sends: String::from("Hello from client!") });
|
||||
|
||||
let response = client.get_something(request).await?;
|
||||
let my_real_request = SomeRequest { what_client_sends: String::from("Hello from client!") };
|
||||
let mut grpc_wrapped_request = Request::new(my_real_request.clone());
|
||||
let signature: MetadataValue<_> = format!("I am a signature of {my_real_request:?}").parse()?;
|
||||
grpc_wrapped_request.metadata_mut().insert("request-signature", signature.clone());
|
||||
let response = client.get_something(grpc_wrapped_request).await?;
|
||||
println!("Unary response: {:?}", response.get_ref().what_server_sends);
|
||||
|
||||
let messages = vec![
|
||||
|
@ -1,4 +1,5 @@
|
||||
mod grpc;
|
||||
use dashmap::DashMap;
|
||||
use grpc::dummy;
|
||||
use std::pin::Pin;
|
||||
use tokio_stream::{wrappers::ReceiverStream, Stream, StreamExt};
|
||||
@ -12,7 +13,9 @@ use dummy::{
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct MyTestService;
|
||||
pub struct MyTestService {
|
||||
challenges: DashMap<String, String>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl TestService for MyTestService {
|
||||
@ -21,6 +24,7 @@ impl TestService for MyTestService {
|
||||
request: Request<SomeRequest>,
|
||||
) -> Result<Response<SomeResponse>, Status> {
|
||||
println!("Got a request from the client: {:?}", request.get_ref().what_client_sends);
|
||||
println!("Get something receied: {:?}", request.metadata().get("request-signature"));
|
||||
|
||||
let reply = SomeResponse {
|
||||
what_server_sends: format!(
|
||||
@ -36,10 +40,9 @@ impl TestService for MyTestService {
|
||||
&self,
|
||||
request: Request<tonic::Streaming<StreamRequest>>,
|
||||
) -> Result<Response<Empty>, Status> {
|
||||
println!("Client started streaming... {:?}", request.metadata().get("authorization"));
|
||||
let mut stream = request.into_inner();
|
||||
|
||||
println!("Client started streaming...");
|
||||
|
||||
while let Some(result) = stream.next().await {
|
||||
match result {
|
||||
Ok(msg) => {
|
||||
|
Loading…
Reference in New Issue
Block a user