pub struct BigTableClientImpl { /* private fields */ }
Expand description
Wrapper for the BigTable connection
Implementations§
source§impl BigTableClientImpl
impl BigTableClientImpl
Connect to a BigTable storage model.
BigTable is available via the Google Console, and is a schema less storage system.
The db_dsn
string should be in the form of
grpc://{BigTableEndpoint}
The settings contains the table_name
which is the GRPC path to the data.
(e.g. projects/{project_id}/instances/{instance_id}/tables/{table_id}
)
where:
BigTableEndpoint is the endpoint domain to use (the default is bigtable.googleapis.com
) See
BigTable Endpoints for more details.
project-id is the Google project identifier (see the Google developer console (e.g. ‘autopush-dev’))
instance-id is the Google project instance, (see the Google developer console (e.g. ‘development-1’))
table_id is the Table Name (e.g. ‘autopush’)
This will automatically bring in the default credentials specified by the GOOGLE_APPLICATION_CREDENTIALS
environment variable.
NOTE: Some configurations may look for the default credential file (pointed to by
GOOGLE_APPLICATION_CREDENTIALS
) to be stored in
$HOME/.config/gcloud/application_default_credentials.json
)
pub fn new(metrics: Arc<StatsdClient>, settings: &DbSettings) -> DbResult<Self>
sourcepub fn spawn_sweeper(&self, interval: Duration)
pub fn spawn_sweeper(&self, interval: Duration)
Spawn a task to periodically evict idle connections
Trait Implementations§
source§impl Clone for BigTableClientImpl
impl Clone for BigTableClientImpl
source§fn clone(&self) -> BigTableClientImpl
fn clone(&self) -> BigTableClientImpl
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl DbClient for BigTableClientImpl
impl DbClient for BigTableClientImpl
source§fn add_user<'life0, 'life1, 'async_trait>(
&'life0 self,
user: &'life1 User,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_user<'life0, 'life1, 'async_trait>(
&'life0 self,
user: &'life1 User,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
add user to the database
source§fn update_user<'life0, 'life1, 'async_trait>(
&'life0 self,
user: &'life1 mut User,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update_user<'life0, 'life1, 'async_trait>(
&'life0 self,
user: &'life1 mut User,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
BigTable doesn’t really have the concept of an “update”. You simply write the data and the individual cells create a new version. Depending on the garbage collection rules for the family, these can either persist or be automatically deleted.
NOTE: This function updates the key ROUTER records for a given UAID. It does this by
calling BigTableClientImpl::user_to_row which creates a new row with new cell.timestamp
values set
to now + MAX_ROUTER_TTL
. This function is called by mobile during the daily
[autoendpoint::routes::update_token_route] handling, and by desktop
[autoconnect-ws-sm::get_or_create_user]which is called during the
HELLO` handler. This should be enough to ensure that the ROUTER records
are properly refreshed for “lively” clients.
NOTE: There is some, very small, potential risk that a desktop client that can somehow remain connected the duration of MAX_ROUTER_TTL, may be dropped as not being “lively”.
source§fn add_channels<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
channels: HashSet<Uuid>,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_channels<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
channels: HashSet<Uuid>,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Add channels in bulk (used mostly during migration)
source§fn remove_channel<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
channel_id: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn remove_channel<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
channel_id: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Delete the channel. Does not delete its associated pending messages.
source§fn remove_node_id<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
_node_id: &'life2 str,
_connected_at: u64,
version: &'life3 Option<Uuid>,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn remove_node_id<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
_node_id: &'life2 str,
_connected_at: u64,
version: &'life3 Option<Uuid>,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Remove the node_id
source§fn save_message<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
message: Notification,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save_message<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
message: Notification,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Write the notification to storage.
source§fn save_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
messages: Vec<Notification>,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
messages: Vec<Notification>,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Save a batch of messages to the database.
Currently just iterating through the list and saving one at a time. There’s a bulk way to save messages, but there are other considerations (e.g. mutation limits)
source§fn increment_storage<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
timestamp: u64,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn increment_storage<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
timestamp: u64,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Set the current_timestamp
in the meta record for this user agent.
This is a bit different for BigTable. Field expiration (technically cell expiration) is determined by the lifetime assigned to the cell once it hits a given date. That means you can’t really extend a lifetime by adjusting a single field. You’d have to adjust all the cells that are in the family. So, we’re not going to do expiration that way.
That leaves the meta “current_timestamp” field. We do not purge ACK’d records,
instead we presume that the TTL will kill them off eventually. On reads, we use
the current_timestamp
to determine what records to return, since we return
records with timestamps later than current_timestamp
.
source§fn remove_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
chidmessageid: &'life2 str,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn remove_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
chidmessageid: &'life2 str,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Delete the notification from storage.
source§fn fetch_topic_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
limit: usize,
) -> Pin<Box<dyn Future<Output = DbResult<FetchMessageResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn fetch_topic_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
limit: usize,
) -> Pin<Box<dyn Future<Output = DbResult<FetchMessageResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Return limit
pending messages from storage. limit=0
for all messages.
source§fn fetch_timestamp_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
timestamp: Option<u64>,
limit: usize,
) -> Pin<Box<dyn Future<Output = DbResult<FetchMessageResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn fetch_timestamp_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
timestamp: Option<u64>,
limit: usize,
) -> Pin<Box<dyn Future<Output = DbResult<FetchMessageResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Return limit
messages pending for a UAID that have a sortkey_timestamp after
what’s specified. limit=0
for all messages.
source§fn router_table_exists<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn router_table_exists<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns true, because there’s only one table in BigTable. We divide things up
by family
.
source§fn message_table_exists<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn message_table_exists<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns true, because there’s only one table in BigTable. We divide things up
by family
.
source§fn get_user<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<Option<User>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_user<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<Option<User>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
source§fn remove_user<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove_user<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
source§fn add_channel<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
channel_id: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn add_channel<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
channel_id: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
source§fn get_channels<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<HashSet<Uuid>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_channels<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<HashSet<Uuid>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
source§fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn box_clone(&self) -> Box<dyn DbClient>
source§fn name(&self) -> String
fn name(&self) -> String
source§fn pool_status(&self) -> Option<Status>
fn pool_status(&self) -> Option<Status>
Auto Trait Implementations§
impl Freeze for BigTableClientImpl
impl !RefUnwindSafe for BigTableClientImpl
impl Send for BigTableClientImpl
impl Sync for BigTableClientImpl
impl Unpin for BigTableClientImpl
impl !UnwindSafe for BigTableClientImpl
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)