You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've discovered a problem using tonic lib for our rust client, trying to send streaming messages, seems like tonic recreate the stream on every message, so more featured server which logic is concreted to listen same stream(for perfomance, resources issues, etc), receiving complete stream signals and new one being created
`
fn send() {
let data = SomeData {
...data
};
let response = match self.client.put_data(tokio_stream::iter(vec![data])).await {
Ok(res) => res,
Err(st) => ...fail processing,
};
}
`
i am suspicious that put_data(tokio_stream::iter(vec![data]) is recreating stream on each send() function call
is there anyway to avoid such behavior? maybe different approach with example?
i saw the way with channels like so
let (tx, rx) = mpsc::unbounded_channel(); let stream = UnboundedReceiverStream::<SomeData>::new(rx);
and then pass the stream directly to client.put_data like so
let response = match self.client.put_data(self.stream)
but here's the same problem, stream will be recreated each time and if i want to store that stream in the struct i cannot move it then later, so i cannot just spawn task with infinite loop, cause i need to process data from response streams, is there any way to solve this issue?
Uh oh!
There was an error while loading. Please reload this page.
We've discovered a problem using tonic lib for our rust client, trying to send streaming messages, seems like tonic recreate the stream on every message, so more featured server which logic is concreted to listen same stream(for perfomance, resources issues, etc), receiving complete stream signals and new one being created
`
fn send() {
let data = SomeData {
...data
};
let response = match self.client.put_data(tokio_stream::iter(vec![data])).await {
Ok(res) => res,
Err(st) => ...fail processing,
};
}
`
i am suspicious that put_data(tokio_stream::iter(vec![data]) is recreating stream on each send() function call
example in repo have the same behavior https://github.com/hyperium/tonic/blob/master/examples/src/streaming/client.rs#L35
is there anyway to avoid such behavior? maybe different approach with example?
i saw the way with channels like so
let (tx, rx) = mpsc::unbounded_channel(); let stream = UnboundedReceiverStream::<SomeData>::new(rx);
and then pass the stream directly to client.put_data like so
let response = match self.client.put_data(self.stream)
but here's the same problem, stream will be recreated each time and if i want to store that stream in the struct i cannot move it then later, so i cannot just spawn task with infinite loop, cause i need to process data from response streams, is there any way to solve this issue?
what i want basically something like https://grpc.io/docs/languages/go/basics/#client-side-streaming-rpc-1
where i can initiate stream like so stream, err := client.RecordRoute(context.Background())
and then use it across entire app
if err := stream.Send(point); err != nil {
log.Fatalf("%v.Send(%v) = %v", stream, point, err)
}
The text was updated successfully, but these errors were encountered: