Struct autopush_common::db::bigtable::BigTableClientImpl

source ·
pub struct BigTableClientImpl { /* private fields */ }
Expand description

Wrapper for the BigTable connection

Implementations§

source§

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)

source

pub fn new(metrics: Arc<StatsdClient>, settings: &DbSettings) -> DbResult<Self>

source

pub fn spawn_sweeper(&self, interval: Duration)

Spawn a task to periodically evict idle connections

Trait Implementations§

source§

impl Clone for BigTableClientImpl

source§

fn clone(&self) -> BigTableClientImpl

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

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,

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,

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 theHELLO` 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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

Read a user from the database
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,

Delete a user from the router table
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,

Add a channel to a user
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,

Get the set of channel IDs for a user
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,

Perform the health check on this data store
source§

fn box_clone(&self) -> Box<dyn DbClient>

source§

fn name(&self) -> String

Provide the module name. This was added for simple dual mode testing (legacy), but may be useful in other situations.
source§

fn pool_status(&self) -> Option<Status>

Return the current deadpool Status (if using deadpool)

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more