pub struct SessionRepository { /* private fields */ }Implementations§
Source§impl SessionRepository
impl SessionRepository
pub async fn fingerprint_session_ids( &self, fingerprint: &str, window_days: i64, ) -> Result<Vec<SessionId>>
pub async fn count_active_fingerprint( &self, fingerprint_hash: &str, ) -> Result<i32>
pub async fn find_reusable_fingerprint( &self, fingerprint_hash: &str, ) -> Result<Option<SessionId>>
Source§impl SessionRepository
impl SessionRepository
pub fn new(db: &DbPool) -> Self
pub async fn find_by_id( &self, session_id: &SessionId, ) -> Result<Option<AnalyticsSession>>
pub async fn find_active_by_id( &self, session_id: &SessionId, ) -> Result<Option<ActiveSessionLookup>>
pub async fn revoke_session(&self, session_id: &SessionId) -> Result<()>
pub async fn revoke_all_for_user(&self, user_id: &UserId) -> Result<u64>
pub async fn find_by_fingerprint( &self, fingerprint_hash: &str, user_id: &UserId, ) -> Result<Option<AnalyticsSession>>
pub async fn list_active_by_user( &self, user_id: &UserId, ) -> Result<Vec<AnalyticsSession>>
pub async fn increment_request_count( &self, session_id: &SessionId, ) -> Result<()>
pub async fn increment_task_count(&self, session_id: &SessionId) -> Result<()>
pub async fn increment_message_count( &self, session_id: &SessionId, ) -> Result<()>
pub async fn end_session(&self, session_id: &SessionId) -> Result<()>
pub async fn mark_as_scanner(&self, session_id: &SessionId) -> Result<()>
pub async fn mark_converted(&self, session_id: &SessionId) -> Result<()>
pub async fn mark_as_behavioral_bot( &self, session_id: &SessionId, reason: &str, ) -> Result<()>
pub async fn check_and_mark_behavioral_bot( &self, session_id: &SessionId, request_count_threshold: i32, ) -> Result<bool>
pub async fn cleanup_inactive(&self, inactive_hours: i32) -> Result<u64>
pub async fn count_inactive(&self, inactive_hours: i32) -> Result<i64>
pub async fn count_sessions_missing_geo(&self) -> Result<i64>
pub async fn migrate_user_sessions( &self, old_user_id: &UserId, new_user_id: &UserId, ) -> Result<u64>
pub async fn create_session( &self, params: &CreateSessionParams<'_>, ) -> Result<()>
pub async fn find_recent_anonymous_by_fingerprint( &self, fingerprint_hash: &str, max_age_seconds: i64, ) -> Result<Option<SessionRecord>>
pub async fn increment_ai_usage( &self, session_id: &SessionId, tokens: i32, cost_microdollars: i64, ) -> Result<()>
pub async fn update_behavioral_detection( &self, session_id: &SessionId, score: i32, is_behavioral_bot: bool, reason: Option<&str>, ) -> Result<()>
pub async fn count_sessions_by_fingerprint( &self, fingerprint_hash: &str, window_hours: i64, ) -> Result<i64>
pub async fn get_session_for_behavioral_analysis( &self, session_id: &SessionId, ) -> Result<Option<SessionBehavioralData>>
pub async fn count_unique_ips_by_fingerprint( &self, fingerprint_hash: &str, window_days: i64, ) -> Result<i64>
pub async fn get_session_starts_by_fingerprint( &self, fingerprint_hash: &str, window_days: i64, ) -> Result<Vec<DateTime<Utc>>>
pub async fn get_session_velocity( &self, session_id: &SessionId, ) -> Result<(Option<i64>, Option<i64>)>
Source§impl SessionRepository
impl SessionRepository
pub async fn create_analytics_session( &self, input: CreateSessionInput<'_>, ) -> Result<()>
Trait Implementations§
Source§impl Clone for SessionRepository
impl Clone for SessionRepository
Source§impl Debug for SessionRepository
impl Debug for SessionRepository
Source§impl SessionProvider for SessionRepository
impl SessionProvider for SessionRepository
fn create_session<'life0, 'life1, 'async_trait>(
&'life0 self,
input: CreateSessionInput<'life1>,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_recent_session_by_fingerprint<'life0, 'life1, 'async_trait>(
&'life0 self,
fingerprint: &'life1 str,
max_age_seconds: i64,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<Option<AnalyticsSession>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_session_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<Option<AnalyticsSession>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_active_session_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<Option<ActiveSession>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn revoke_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn revoke_all_sessions_for_user<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 UserId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn migrate_user_sessions<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from_user_id: &'life1 UserId,
to_user_id: &'life2 UserId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn mark_session_converted<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§impl SessionStore for SessionRepository
impl SessionStore for SessionRepository
fn fingerprint_session_ids<'life0, 'life1, 'async_trait>(
&'life0 self,
fingerprint: &'life1 str,
window_days: i64,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<Vec<SessionId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<Option<SessionSnapshot>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_active_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<Option<ActiveSessionLookup>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn revoke_all_for_user<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 UserId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_by_fingerprint<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
fingerprint_hash: &'life1 str,
user_id: &'life2 UserId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<Option<SessionSnapshot>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn list_active_by_user<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 UserId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<Vec<SessionSnapshot>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn increment_request_count<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn end_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn mark_as_scanner<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn mark_converted<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn mark_as_behavioral_bot<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn check_and_mark_behavioral_bot<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
request_count_threshold: i32,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn cleanup_inactive<'life0, 'async_trait>(
&'life0 self,
inactive_hours: i32,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn count_inactive<'life0, 'async_trait>(
&'life0 self,
inactive_hours: i32,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<i64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn count_sessions_missing_geo<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<i64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn insert_session<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
params: &'life1 CreateSessionParams<'life2>,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn find_recent_by_fingerprint<'life0, 'life1, 'async_trait>(
&'life0 self,
fingerprint_hash: &'life1 str,
max_age_seconds: i64,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<Option<SessionRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn increment_ai_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
tokens: i32,
cost_microdollars: i64,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update_behavioral_detection<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
score: i32,
is_behavioral_bot: bool,
reason: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn count_sessions_by_fingerprint<'life0, 'life1, 'async_trait>(
&'life0 self,
fingerprint_hash: &'life1 str,
window_hours: i64,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<i64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_session_for_behavioral_analysis<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<Option<SessionBehavioralData>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn count_unique_ips_by_fingerprint<'life0, 'life1, 'async_trait>(
&'life0 self,
fingerprint_hash: &'life1 str,
window_days: i64,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<i64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_session_starts_by_fingerprint<'life0, 'life1, 'async_trait>(
&'life0 self,
fingerprint_hash: &'life1 str,
window_days: i64,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<Vec<DateTime<Utc>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_session_velocity<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<(Option<i64>, Option<i64>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn count_active_fingerprint_sessions<'life0, 'life1, 'async_trait>(
&'life0 self,
fingerprint: &'life1 str,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<i32>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_reusable_fingerprint_session<'life0, 'life1, 'async_trait>(
&'life0 self,
fingerprint: &'life1 str,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<Option<SessionId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sessions_missing_geo<'life0, 'life1, 'async_trait>(
&'life0 self,
after: Option<&'life1 SessionId>,
limit: i64,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<Vec<(SessionId, String)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_session_geo<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
country: Option<&'life2 str>,
region: Option<&'life3 str>,
city: Option<&'life4 str>,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Source§impl SessionUsageCounters for SessionRepository
impl SessionUsageCounters for SessionRepository
fn increment_task_count<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn increment_message_count<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = AnalyticsResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for SessionRepository
impl !UnwindSafe for SessionRepository
impl Freeze for SessionRepository
impl Send for SessionRepository
impl Sync for SessionRepository
impl Unpin for SessionRepository
impl UnsafeUnpin for SessionRepository
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more