-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Feature Request
Crates
Main Crate
Motivation
I'm trying to output a unidirectional tonic gRPC stream via SSE using warp. I'm using warp from seanmonstar/warp#265 to be able to use it with async await. Changing warp to be compatible with async / await requires that all responses handed over to warp (and in turn handed over to hyper) to be Sync. However, the stream returned from a streaming gRPC response is not Sync.
Proposal
Rustc complains that the decoder specifically is the part that is not sync:
tonic/tonic/src/codec/decode.rs
Line 22 in 5d0a795
| decoder: Box<dyn Decoder<Item = T, Error = Status> + Send + 'static>, |
As far as I can see, decoder is not accessible from the outside, and thus it should be safe to mark the whole Streaming struct as Sync. I would be happy to file a PR for that.
Alternatives
I don't see any, because AFAIK the Sync bound stems from a layer deep down inside hyper, and I guess it's unfeasible to change that somehow to remove it.