pub struct PgClientImpl { /* private fields */ }Implementations§
Source§impl PgClientImpl
impl PgClientImpl
Sourcepub fn new(metrics: Arc<StatsdClient>, settings: &DbSettings) -> DbResult<Self>
pub fn new(metrics: Arc<StatsdClient>, settings: &DbSettings) -> DbResult<Self>
Create a new Postgres Client.
This uses the settings.db_dsn. to try and connect to the postgres database.
See https://docs.rs/tokio-postgres/latest/tokio_postgres/config/struct.Config.html
for parameter details and requirements.
Example DSN: postgresql://user:password@host/database?option=val
e.g. (postgresql://scott:tiger@dbhost/autopush?connect_timeout=10&keepalives_idle=3600)
Trait Implementations§
Source§impl Clone for PgClientImpl
impl Clone for PgClientImpl
Source§fn clone(&self) -> PgClientImpl
fn clone(&self) -> PgClientImpl
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl DbClient for PgClientImpl
impl DbClient for PgClientImpl
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 router_table if not exists uaid
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,
update user record in router_table at user.uaid
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,
fetch user information from router_table for uaid.
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,
delete a user at uaid from 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,
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,
update list of channel_ids for uaid in meta table Note: a conflicting channel_id is ignored, since it’s already registered. This should probably be optimized into the router table as a set value, however I’m not familiar enough with Postgres to do so at this time. Channels can be somewhat ephemeral, and we also want to limit the potential of race conditions when adding or removing channels, particularly for mobile devices. For some efficiency (mostly around the mobile “daily refresh” call), I’ve broken the channels out by UAID into this table.
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,
Save all channels in a list
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,
get all channels for uaid from meta table
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,
remove an individual channel for a given uaid from meta table
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 node info for a uaid from router table
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 a message to message table
Source§fn remove_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
sort_key: &'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,
sort_key: &'life2 str,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
remove a given message from the message table
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,
fetch topic messages for the user up to {limit} Topic messages are auto-replacing singleton messages for a given user.
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,
Fetch messages for a user on or after a given timestamp up to {limit}
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,
Convenience function to check if the router table exists
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,
Convenience function to check if the message table exists
Source§fn box_clone(&self) -> Box<dyn DbClient>
fn box_clone(&self) -> Box<dyn DbClient>
Convenience function to return self as a Boxed DbClient