Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyera Eulberg committed Nov 16, 2023
1 parent 32294bf commit 33f2c58
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions storage-bigtable/src/bigtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ pub enum Error {
Timeout,
}

fn check_table_not_found<T>(result: Result<T>) -> std::result::Result<T, BackoffError<Error>> {
if let Err(Error::Rpc(ref err)) = result {
if err.code() == tonic::Code::NotFound && err.message().starts_with("table") {
return Err(BackoffError::Permanent(Error::Rpc(err.clone())));
fn to_backoff_err(err: Error) -> BackoffError<Error> {
if let Error::Rpc(ref status) = err {
if status.code() == tonic::Code::NotFound && status.message().starts_with("table") {
return BackoffError::Permanent(err);
}
}
Ok(result?)
err.into()
}

impl std::convert::From<std::io::Error> for Error {
Expand Down Expand Up @@ -275,7 +275,7 @@ impl BigTableConnection {
retry(ExponentialBackoff::default(), || async {
let mut client = self.client();
let result = client.put_bincode_cells(table, cells).await;
check_table_not_found(result)
result.map_err(to_backoff_err)
})
.await
}
Expand Down Expand Up @@ -314,7 +314,7 @@ impl BigTableConnection {
retry(ExponentialBackoff::default(), || async {
let mut client = self.client();
let result = client.put_protobuf_cells(table, cells).await;
check_table_not_found(result)
result.map_err(to_backoff_err)
})
.await
}
Expand Down

0 comments on commit 33f2c58

Please sign in to comment.