PgClientImpl

Struct PgClientImpl 

Source
pub struct PgClientImpl { /* private fields */ }

Implementations§

Source§

impl PgClientImpl

Source

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

Source§

fn clone(&self) -> PgClientImpl

Returns a duplicate 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 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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

Convenience function to check if the message table exists

Source§

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

Convenience function to return self as a Boxed DbClient

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 multiple messages to the message table
Source§

fn log_report<'life0, 'life1, 'async_trait>( &'life0 self, reliability_id: &'life1 str, new_state: ReliabilityState, ) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Record the Reliability Report to long term storage.
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,

Update the last read timestamp for a user
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 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 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 + Send + Sync>

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
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