db_manager_connection - OmniCloudOrg/OmniOrchestrator GitHub Wiki

connection (src/db_manager)

Path: src/db_manager/connection.rs

Table of Contents

Public Items

struct ConnectionManager

Definition

pub struct ConnectionManager {
    /// Base URL for database connections
    base_url: String,
    
    /// Main application database pool
    main_pool: Pool<MySql>,
    
    /// Platform-specific database pools
    platform_pools: Arc<RwLock<HashMap<i64, Pool<MySql>>>>,
}

Documentation

Manages database connections across the application

async fn new

Definition

    pub async fn new(base_url: &str) -> Result<Self, DatabaseError> {
        // Connect to the MySQL server without specifying a database
        info!("Connecting to MySQL server at {}", base_url);

Documentation

Creates a new connection manager

async fn ensure_database_exists

Definition

    pub async fn ensure_database_exists(pool: &Pool<MySql>, db_name: &str) -> Result<(), DatabaseError> {
        info!("Ensuring database exists: {}", db_name);

Documentation

Ensures a database exists, creating it if necessary

fn main_pool

Definition

    pub fn main_pool(&self) -> &Pool<MySql> {
        &self.main_pool
    }
    
    /// Gets or creates a platform-specific database pool
    pub async fn platform_pool(&self, platform_id: i64, platform_name: &str) -> Result<Pool<MySql>, DatabaseError> {
    // ... function body
}

Documentation

Gets the main database pool

async fn platform_pool

Definition

    pub async fn platform_pool(&self, platform_id: i64, platform_name: &str) -> Result<Pool<MySql>, DatabaseError> {
        // Check if we already have this pool
        {
    // ... function body
}

Documentation

Gets or creates a platform-specific database pool

⚠️ **GitHub.com Fallback** ⚠️