feat(transport): Change channel connect to be async (#107)

This makes it so you can check if the initial connection
is established. Before this we used reconnect which would
lazily attempt to connect. So if you were trying to connect
to a non existant Server you wouldn't find out until after
you attempted your first RPC. This simplifies everything
by allowing you connect before creating the RPC client.

BREAKING CHANGE: `Endpoint::channel` was removed in favor of
an async `Endpoint::connect`.
This commit is contained in:
Lucio Franco
2019-10-31 14:09:40 -04:00
committed by GitHub
parent 108bad0d86
commit 5c2f4dba32
18 changed files with 243 additions and 38 deletions
+3 -1
View File
@@ -12,7 +12,9 @@ use tonic::transport::Endpoint;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let channel = Endpoint::from_static("http://[::1]:50051").channel();
let channel = Endpoint::from_static("http://[::1]:50051")
.connect()
.await?;
let mut greeter_client = GreeterClient::new(channel.clone());
let mut echo_client = EchoClient::new(channel);