I have N input streams (queues) and N corresponding connections. A scheduler thread scans the incoming requests, prioritizes them based on some criteria, and sends them out on the respective connections (request from in queue x goes on connection x). Similar thing happens on the receive side as well.
In a traditional setting, one would create the connections with O_NONBLOCK. If the write to a connection is going to block, leave the request in the input queue, and revisit the queue later so the scheduler thread is not blocked on one slow connection.
Is such a thing possible with tokio::net::TcpStream, etc? It looks like there was tokio::io::{TryRead, TryWrite} in the past that got removed.
One option might be to create an out queue per-connection, with a dedicated task per out queue. This just dequeues and does write_all().await on the connection. This creates one more hop, and adds to the complexity. Makes me wonder if Tokio is the right choice for this application.