pub struct RedisClientImpl {
pub client: Client,
pub conn: OnceCell<MultiplexedConnection>,
/* private fields */
}Expand description
Wrapper for the Redis connection
Fields§
§client: ClientDatabase connector string
conn: OnceCell<MultiplexedConnection>Implementations§
Source§impl RedisClientImpl
impl RedisClientImpl
pub fn new(metrics: Arc<StatsdClient>, settings: &DbSettings) -> DbResult<Self>
Trait Implementations§
Source§impl Clone for RedisClientImpl
impl Clone for RedisClientImpl
Source§fn clone(&self) -> RedisClientImpl
fn clone(&self) -> RedisClientImpl
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl DbClient for RedisClientImpl
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,
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,
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,
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.
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,
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,
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,
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,
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,
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,
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,
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