diff --git a/autopush-common/src/db/bigtable/bigtable_client/mod.rs b/autopush-common/src/db/bigtable/bigtable_client/mod.rs index e2f1e430..83541945 100644 --- a/autopush-common/src/db/bigtable/bigtable_client/mod.rs +++ b/autopush-common/src/db/bigtable/bigtable_client/mod.rs @@ -29,7 +29,7 @@ use crate::db::{ }; pub use self::metadata::MetadataBuilder; -use self::row::Row; +use self::row::{Row, RowCells}; use super::pool::BigTablePool; use super::BigTableDbSettings; @@ -204,10 +204,10 @@ fn to_string(value: Vec, name: &str) -> Result { /// Parse the "set" (see [DbClient::add_channels]) of channel ids in a bigtable Row. /// -/// The row should solely contain the set of channels otherwise an Error is returned. -fn channels_from_row(row: &row::Row) -> DbResult> { +/// Cells should solely contain the set of channels otherwise an Error is returned. +fn channels_from_cells(cells: &RowCells) -> DbResult> { let mut result = HashSet::new(); - for cells in row.cells.values() { + for cells in cells.values() { let Some(cell) = cells.last() else { continue; }; @@ -322,7 +322,7 @@ pub fn retryable_error(metrics: Arc) -> impl Fn(&grpcio::Error) -> /// 2) When router TTLs are eventually enabled: `add_channel` and /// `increment_storage` can write cells with later expiry times than the other /// router cells -fn is_incomplete_router_record(cells: &HashMap>) -> bool { +fn is_incomplete_router_record(cells: &RowCells) -> bool { cells .keys() .all(|k| ["current_timestamp", "version"].contains(&k.as_str()) || k.starts_with("chid:")) @@ -986,7 +986,7 @@ impl DbClient for BigTableClientImpl { } // Read the channels last, after removal of all non channel cells - result._channels = channels_from_row(&row)?; + result._channels = channels_from_cells(&row.cells)?; Ok(Some(result)) } @@ -1049,7 +1049,7 @@ impl DbClient for BigTableClientImpl { let Some(row) = self.read_row(req).await? else { return Ok(Default::default()); }; - channels_from_row(&row) + channels_from_cells(&row.cells) } /// Delete the channel. Does not delete its associated pending messages. diff --git a/autopush-common/src/db/bigtable/bigtable_client/row.rs b/autopush-common/src/db/bigtable/bigtable_client/row.rs index 2ace5d8c..2f5bbd41 100644 --- a/autopush-common/src/db/bigtable/bigtable_client/row.rs +++ b/autopush-common/src/db/bigtable/bigtable_client/row.rs @@ -4,6 +4,8 @@ use crate::db::error::{DbError, DbResult}; use super::{cell::Cell, RowKey}; +pub type RowCells = HashMap>; + /// A Bigtable storage row. Bigtable stores by Family ID which isn't /// very useful for us later, so we overload this structure a bit. /// When we read data back out of Bigtable, we index cells by @@ -19,7 +21,7 @@ pub struct Row { pub row_key: RowKey, /// The row's collection of cells, indexed by either the /// FamilyID (for write) or Qualifier (for read). - pub cells: HashMap>, + pub cells: RowCells, } impl Row {