Open elmarco opened 5 years ago
Yeah, in the tokio-qapi async/await implementation I went back and forth a lot about exactly how I wanted to deal with that, and sharing underlying ownership across the one-way event stream and the command/response parts. What it IIRC currently does is:
I think my intention for future improvements was to keep a similar approach but try and make things more ergonomic, and isolate the dispatcher logic into something a bit more clean (use an internal Sink for responses rather than using shared memory?). I intended to also look into tower which I think is supposed to be a building block for RPC style interfaces; not sure if it's overkill, too unstable, supports async-std, but worth noting at least. I got tired of the state of async/await and dealing with the futures 0.1 vs 0.3 compat interface so haven't looked into it in a while.
The future/async stuff is not easy to grasp, I am just playing around.
I have got something sort of working, help & comments are welcome: https://github.com/elmarco/qapi-rs/tree/async/async.
In particular, I am not sure how events should be exposed. I think they should be a Stream, but then it's not obvious to me how another control could "share" the connection and send other commands since a fused stream will own the reference...