#Request-Response style channel type

7 messages · Page 1 of 1 (latest)

lyric karma
#

hiya, i'm looking to build a system in which i can dispatch a set of async tasks (atm using tokio) and then communicate in a request/response style with them. does anyone know of a crate / type within tokio that allows this sort of behaviour? or, is there an easy way to implement this with existing channel types?

winter yacht
lapis laurel
#

there's a general trick for request-response: put the sender of a tokio::sync::oneshot channel inside each of your request messages, which can then convey the response

lyric karma
#

yeah i was considering that but wasnt sure if there was a better solution

lyric karma
#

i think im gonna go with the crossbeam channel and see how it works out

lapis laurel
#

you don't want to use crossbeam channels from async tasks because they have blocking receive, not .await receive