i18n+filtering fork - fluent-templates v2
at main 35 lines 944 B view raw
1use anyhow::Result; 2use deadpool_redis::{Config, Pool, Runtime}; 3 4use crate::storage::errors::CacheError; 5 6pub const OAUTH_REFRESH_QUEUE: &str = "auth_session:oauth:refresh"; 7pub const OAUTH_REFRESH_HEARTBEATS: &str = "auth_session:oauth:refresh:workers"; 8 9pub fn build_worker_queue(worker_id: &str) -> String { 10 format!("{}:{}", OAUTH_REFRESH_QUEUE, worker_id) 11} 12 13pub fn create_cache_pool(redis_url: &str) -> Result<Pool> { 14 let cfg = Config::from_url(redis_url); 15 cfg.create_pool(Some(Runtime::Tokio1)) 16 .map_err(|err| CacheError::FailedToCreatePool(err).into()) 17} 18 19// Mock implementation for testing 20#[cfg(test)] 21pub struct MockCachePool {} 22 23#[cfg(test)] 24impl std::fmt::Debug for MockCachePool { 25 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 26 f.debug_struct("MockCachePool").finish() 27 } 28} 29 30#[cfg(test)] 31impl Clone for MockCachePool { 32 fn clone(&self) -> Self { 33 Self {} 34 } 35}