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