use crate::session::id::SessionId;
pub(super) const DEFAULT_PREFIX: &str = "axess";
pub(super) const DEFAULT_MAX_PAYLOAD_BYTES: usize = 64 * 1024;
pub(super) fn session_key(prefix: &str, id: &SessionId) -> String {
format!("{prefix}:sess:{id}")
}
pub(super) fn registry_key(prefix: &str, user_id: &str) -> String {
format!("{prefix}:reg:{user_id}")
}
pub(super) fn revocation_session_channel(prefix: &str, session_id: &str) -> String {
format!("{prefix}:revoked-session:{session_id}")
}
pub(super) fn revocation_user_channel(prefix: &str, user_id: &str) -> String {
format!("{prefix}:revoked-user:{user_id}")
}
#[derive(Debug, thiserror::Error)]
pub enum ValkeyStoreError {
#[error("connection error: {0}")]
Connection(#[source] fred::error::Error),
#[error("codec error: {0}")]
Codec(#[from] crate::session::storage::session_codec::SqlStoreError),
#[error("encoded session payload too large ({size} bytes, max {max} bytes)")]
PayloadTooLarge {
size: usize,
max: usize,
},
}
impl From<fred::error::Error> for ValkeyStoreError {
fn from(e: fred::error::Error) -> Self {
Self::Connection(e)
}
}