This PR explores the idea of extending the transport interfaces, where applicable, with run() and query() style interfaces.
run simplifies usage in the most common case by spawning transport::run() onto a new Tokio task, as new() returns both a transport and a connection and the caller is responsible for spawning transport::run() onto a new tokio task, or running it and awaiting it while passing the connection or a clone of it to another task/thread. When using run() one cannot await the join handle of the spawned task, but there isn't anything one can usefully do with the join handle anyway.
query simplifies usage in the one-shot case, which is unsuitable for sending many queries but maybe useful in demonstration, test or simple client scenarios.
examples/client-transport.rs is extended to show the new interfaces, but in particular if we like run() we might want to simplify the example to use it everywhere and leave new() for advanced scenarios.
This PR explores the idea of extending the transport interfaces, where applicable, with
run()
andquery()
style interfaces.run
simplifies usage in the most common case by spawningtransport::run()
onto a new Tokio task, asnew()
returns both a transport and a connection and the caller is responsible for spawningtransport::run()
onto a new tokio task, or running it and awaiting it while passing the connection or a clone of it to another task/thread. When usingrun()
one cannot await the join handle of the spawned task, but there isn't anything one can usefully do with the join handle anyway.query
simplifies usage in the one-shot case, which is unsuitable for sending many queries but maybe useful in demonstration, test or simple client scenarios.examples/client-transport.rs
is extended to show the new interfaces, but in particular if we likerun()
we might want to simplify the example to use it everywhere and leavenew()
for advanced scenarios.