RedisClientImpl

Struct RedisClientImpl 

Source
pub struct RedisClientImpl {
    pub client: Client,
    pub conn: OnceCell<MultiplexedConnection>,
    /* private fields */
}
Expand description

Wrapper for the Redis connection

Fields§

§client: Client

Database connector string

§conn: OnceCell<MultiplexedConnection>

Implementations§

Source§

impl RedisClientImpl

Source

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

Trait Implementations§

Source§

impl Clone for RedisClientImpl

Source§

fn clone(&self) -> RedisClientImpl

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 RedisClientImpl

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,

To update the TTL of the Redis entry we just have to SET again, with the new expiry

NOTE: 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.

If the message contains a topic, we remove the old message

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,

Delete expired messages

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,

Topic messages are handled as other messages with redis, we return nothing.

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 record timestamp after [timestamp] (secs).

If [limit] = 0, we fetch all messages after [timestamp].

This can return expired messages, following bigtables behavior

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 no table in Redis

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 no table in Redis

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 log_report<'life0, 'life1, 'async_trait>( &'life0 self, reliability_id: &'life1 str, 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 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 + 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