use std::time::Duration; use surrealdb::{ engine::remote::ws::{Client, Ws}, Surreal, }; use tokio::time::sleep; pub async fn establish_connection() -> Surreal { Surreal::new::("localhost:8000").await.unwrap() } pub async fn is_alive(db: Surreal) -> bool { tokio::select! { db_result = db.health() => { match db_result { Ok(_) => true, Err(_) => false, } }, _ = sleep(Duration::from_secs(1)) => false } }