fix(transport): Propagate errors in tls_config instead of unwrap/panic (#385)
* Propagate errors in tls_config instead of unwrap Ran into `tls_connector` failing and causing our app to panic and shutdown as it seems there wasn't any way to avoid panicking in `tls_config`. So after talking to @LucioFranco briefly `tls_config` now returns a `Result` instead and propagates errors to the caller, where they can be handled. * Fix compile warning when tls feature is disabled
This commit is contained in:
@@ -32,7 +32,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.domain_name("pubsub.googleapis.com");
|
||||
|
||||
let channel = Channel::from_static(ENDPOINT)
|
||||
.tls_config(tls_config)
|
||||
.tls_config(tls_config)?
|
||||
.connect()
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.domain_name("example.com");
|
||||
|
||||
let channel = Channel::from_static("http://[::1]:50051")
|
||||
.tls_config(tls)
|
||||
.tls_config(tls)?
|
||||
.connect()
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let server = EchoServer::default();
|
||||
|
||||
Server::builder()
|
||||
.tls_config(ServerTlsConfig::new().identity(identity))
|
||||
.tls_config(ServerTlsConfig::new().identity(identity))?
|
||||
.add_service(pb::echo_server::EchoServer::new(server))
|
||||
.serve(addr)
|
||||
.await?;
|
||||
|
||||
@@ -19,7 +19,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.identity(client_identity);
|
||||
|
||||
let channel = Channel::from_static("http://[::1]:50051")
|
||||
.tls_config(tls)
|
||||
.tls_config(tls)?
|
||||
.connect()
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.client_ca_root(client_ca_cert);
|
||||
|
||||
Server::builder()
|
||||
.tls_config(tls)
|
||||
.tls_config(tls)?
|
||||
.add_service(pb::echo_server::EchoServer::new(server))
|
||||
.serve(addr)
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user