cpex_session_valkey/
factory.rs1use std::sync::Arc;
12
13use apl_cpex::{SessionStore, SessionStoreFactory};
14
15use crate::config::ValkeyConfig;
16use crate::store::ValkeySessionStore;
17
18pub const KIND: &str = "valkey";
21
22#[derive(Default)]
24pub struct ValkeySessionStoreFactory;
25
26impl ValkeySessionStoreFactory {
27 pub fn new() -> Self {
28 Self
29 }
30}
31
32impl SessionStoreFactory for ValkeySessionStoreFactory {
33 fn kind(&self) -> &str {
34 KIND
35 }
36
37 fn build(
38 &self,
39 config: &serde_yaml::Value,
40 ) -> Result<Arc<dyn SessionStore>, Box<dyn std::error::Error + Send + Sync>> {
41 let cfg = ValkeyConfig::from_value(config)?;
42 let store = ValkeySessionStore::from_config(&cfg)?;
43 Ok(Arc::new(store))
44 }
45}