Thanks to visit codestin.com
Credit goes to github.com

Skip to content

v0.3.7

Latest
Compare
Choose a tag to compare
@zhuxiujia zhuxiujia released this 19 May 09:16

what changes?

New Features

  • Added CheckDurationConnectionManager which provides a duration-based connection checking mechanism
    Allows users to set a minimum check interval after connection creation
    Only performs connection checks when connections exceed a specified time threshold, optimizing performance
    Fully compatible with the existing Pool interface for seamless integration
    Supports custom check functions for flexible adaptation to different scenarios
    Technical Details

  • Added CheckMode::Duration option to the checking modes
    Optimized the ConnectionGuard structure with improved time tracking logic
    Added comprehensive test cases to ensure functionality stability

  • use example

use std::time::Duration;
use fast_pool::{Manager, Pool};
use fast_pool::plugin::CheckDurationConnectionManager;

// Assume we have some database manager that implements Manager trait
struct MyDatabaseManager;

impl Manager for MyDatabaseManager {
    type Connection = ();
    type Error = String;
    
    async fn connect(&self) -> Result<Self::Connection, Self::Error> {
        Ok(())
    }
    
    async fn check(&self, _conn: &mut Self::Connection) -> Result<(), Self::Error> {
        Ok(())
    }
}

let base_manager = MyDatabaseManager;
let duration_manager = CheckDurationConnectionManager::new(base_manager, Duration::from_secs(60));
let pool = Pool::new(duration_manager);