Restructure Osiris: separate core, client, and server crates to avoid circular dependencies

This commit is contained in:
Timur Gordon
2025-11-04 13:08:43 +01:00
parent ae846ea734
commit 5d82959457
86 changed files with 601 additions and 62 deletions

55
core/src/config/model.rs Normal file
View File

@@ -0,0 +1,55 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
/// OSIRIS configuration
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Config {
/// HeroDB connection configuration
pub herodb: HeroDbConfig,
/// Namespace configurations
#[serde(default)]
pub namespaces: HashMap<String, NamespaceConfig>,
}
/// HeroDB connection configuration
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct HeroDbConfig {
/// HeroDB URL (e.g., "redis://localhost:6379")
pub url: String,
}
/// Namespace configuration
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct NamespaceConfig {
/// HeroDB database ID for this namespace
pub db_id: u16,
}
impl Config {
/// Get namespace configuration by name
pub fn get_namespace(&self, name: &str) -> Option<&NamespaceConfig> {
self.namespaces.get(name)
}
/// Add or update a namespace
pub fn set_namespace(&mut self, name: String, config: NamespaceConfig) {
self.namespaces.insert(name, config);
}
/// Remove a namespace
pub fn remove_namespace(&mut self, name: &str) -> Option<NamespaceConfig> {
self.namespaces.remove(name)
}
/// Get the next available database ID
pub fn next_db_id(&self) -> u16 {
let max_id = self
.namespaces
.values()
.map(|ns| ns.db_id)
.max()
.unwrap_or(0);
max_id + 1
}
}