Questions tagged [rust-tonic]
37 questions
5
votes
1 answer
How to integration test tonic application
Hi I have a simple application that has one gRPC method it works as expected however I do not know how to correctly integration test it. (I'm new to rust too). i.e. I would like to call gRPC add_merchant method and check if the response contains…

user1048282
- 780
- 1
- 9
- 22
3
votes
0 answers
Tonic annotate only enums at compile time
Using tonic_build I can add .type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]”) to annotate my types with e.g. serde.
However is there a way to only annotate enums, that are in the same package as structs.
Example:
syntax =…

Alex
- 439
- 5
- 16
3
votes
1 answer
tonic_build add/use external crates like serde
I'm trying to use or add an external create like serde, to the build.rs file that tonic_build will use to generate the .rs file from the .proto file.
// build.rs file
let proto_file = "src/hello/hello.proto";
tonic_build::configure()
…

Silva
- 625
- 1
- 6
- 25
3
votes
1 answer
How can I send a message from a standard library spawned thread to a Tokio async task?
I have a setup where my program spawns several threads for CPU-bound computation using the std::thread::spawn.
I need a GRPC server to handle incoming commands and also stream outputs done by the worker threads. I'm using tonic for the GRPC server,…

l3utterfly
- 2,106
- 4
- 32
- 58
2
votes
0 answers
Function to create GRPC server with generic protobuf service and generic tower layer parameters
I'm writing a function fn run_grpc_server(service: S, layer: L) -> Result<(), String> where I need to provide generic parameter for protobuf service S and tower layer L, so I can build the GRPC server combining them.
To illustrate, I modify…

bits
- 1,595
- 1
- 17
- 17
2
votes
1 answer
`Send` is not implemented when attempting Inversion of Control in Rust
Summary
When trying to have a tonic server class depend on a trait, I get a compile-time issue about the trait not implementing Send or Sync. My intent is to have the server class depend on the trait rather than the concrete implementation of that…

san4d
- 71
- 6
2
votes
0 answers
How can I clean up Channels on disconnect for tokio/tonic?
I am implementing a turn-based game server using tonic. I use gRPC streaming for the game so that players get sent updates about the moves their opponents make once they connect, more or less like this (simplified):
service Game {
rpc…

Derek Thurn
- 14,953
- 9
- 42
- 64
2
votes
1 answer
Rust tonic tonic::include_proto file path from one module to another module in tonic build
I am implementing gRPC client and server using Tonic. I have two modules each module depending on another module proto file. I am facing an issue when I try to provide the path of the proto file in tonic build. Below is my folder structure and code…

nagaraj
- 797
- 1
- 6
- 29
2
votes
2 answers
the trait `std::marker::Copy` is not implemented for Type
I'm trying to move some data around b/w different threads but am getting the ole Copy trait-not-implemented error. Here's some code:
use std::future::Future;
use std::marker::PhantomData;
use std::sync::{Arc, Mutex};
/// Start external crates…

Seg
- 23
- 2
- 4
2
votes
0 answers
Is there a way to start both a tonic gRPC and an actix web app within the same main?
I am trying to implement a server that serves both gRPC and REST calls and that is started by a single binary.
In this main function, I am trying to start a tonic gRPC server and an actix-web REST API.
I found this answer but it didn't work for me:…

Carlos Natalino
- 66
- 6
1
vote
0 answers
Server connect to client without needing URL (because client connects first)
In a scenario where the gRPC server doesn't know the URLs of clients in general, but clients know the URL of the (single) server, it would be useful to be able to initiate connections to client endpoints from the server, once a client connects to…

jsstuball
- 4,104
- 7
- 33
- 63
1
vote
1 answer
Is there a way to get Rust tonic gRPC client streams to start without waiting for the first message?
It seems that the following code blocks until the first streamed object arrives:
let mut stream = client
.stream_something(StreamRequest {})
.await
.unwrap()
.into_inner();
Specifically I want to start the stream,…

Thomas
- 4,208
- 2
- 29
- 31
1
vote
0 answers
Error about using axum and tonic together
I'm trying to create a little Grpc-Web Rust server using axum and tonic.
I'm new both to Rust and Grpc.
I managed to generate all the rust code from proto files.
THE REPOSITORY IS HERE: https://github.com/frederikhors/issue-tonic-web
The issue I'm…

Fred Hors
- 3,258
- 3
- 25
- 71
1
vote
1 answer
Unexpected NotValidForName with Rust's tonic with TLS
I am using the Rust's tonic library for GRPC with TLS.
I get the following error
thread 'main' panicked at 'Failed to create request insight client: tonic::transport::Error(Transport,
hyper::Error(Connect, Custom { kind: InvalidData, error:…

dmeister
- 34,704
- 19
- 73
- 95
1
vote
0 answers
Rate-limited stream as tonic grpc stream response
I have a gRPC service written in Rust using the tonic crate. One of the methods of this service returns a stream (server-side grpc streaming) of values which are acquired by calling many devices on the network, which is why I need to rate-limit the…

sveatlo
- 543
- 9
- 27