move repos into monorepo

This commit is contained in:
Timur Gordon
2025-11-13 20:44:00 +01:00
commit 4b23e5eb7f
204 changed files with 33737 additions and 0 deletions

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
}
}