Skip to main content

Module distributed

Module distributed 

Source
Expand description

Distributed authentication: cross-node token validation and cluster coordination. Distributed session store abstraction.

Provides a trait for querying the total number of active sessions across all instances in a distributed deployment. A no-op [LocalOnlySessionStore] is provided for single-node use; it always reports zero total sessions, which causes AuthFramework’s remote-session estimate logic to return 0 instead of an incorrect local_count * 2 estimate.

§Production integration

To use Redis (or any key–value store) as the distributed session backend, implement this trait and inject it via AuthFramework::set_distributed_store:

use std::sync::Arc;
use auth_framework::distributed::DistributedSessionStore;
use auth_framework::errors::Result;
use async_trait::async_trait;

// Example: wrap your chosen backend (e.g., a Redis client) in this struct.
struct MySessionStore {
    // inner: redis::Client,  // fill in your backend type
}

#[async_trait]
impl DistributedSessionStore for MySessionStore {
    async fn total_session_count(&self) -> Result<u64> {
        // Query DBSIZE or scan session keys in your backend.
        Ok(42)
    }
}

let mut framework = auth_framework::AuthFramework::builder().build().await?;
framework.set_distributed_store(Arc::new(MySessionStore {}));

Modules§

rate_limiting
Distributed Rate Limiting System

Structs§

LocalOnlySessionStore
No-op store used when no distributed backend is configured.

Traits§

DistributedSessionStore
Abstraction over a distributed session backend.