2023-05-22 19:19:35 +00:00
|
|
|
use crate::cli::abstraction::DatabaseConnectionArguments;
|
2023-03-07 09:53:56 +00:00
|
|
|
use crate::err::Error;
|
2023-05-22 19:19:35 +00:00
|
|
|
use clap::Args;
|
2023-03-07 09:53:56 +00:00
|
|
|
use surrealdb::engine::any::connect;
|
|
|
|
|
2023-05-22 19:19:35 +00:00
|
|
|
#[derive(Args, Debug)]
|
|
|
|
pub struct IsReadyCommandArguments {
|
|
|
|
#[command(flatten)]
|
|
|
|
conn: DatabaseConnectionArguments,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn init(
|
|
|
|
IsReadyCommandArguments {
|
|
|
|
conn: DatabaseConnectionArguments {
|
|
|
|
endpoint,
|
|
|
|
},
|
|
|
|
}: IsReadyCommandArguments,
|
|
|
|
) -> Result<(), Error> {
|
2023-03-29 18:16:18 +00:00
|
|
|
// Initialize opentelemetry and logging
|
|
|
|
crate::o11y::builder().with_log_level("error").init();
|
2023-03-07 09:53:56 +00:00
|
|
|
// Connect to the database engine
|
2023-04-24 09:50:03 +00:00
|
|
|
connect(endpoint).await?;
|
2023-03-07 09:53:56 +00:00
|
|
|
println!("OK");
|
|
|
|
Ok(())
|
|
|
|
}
|