Add a versioned backend catalog and YAML deployment configuration
This commit is contained in:
+16
-10
@@ -1,19 +1,25 @@
|
||||
use std::{env, error::Error, fs};
|
||||
use std::{env, error::Error};
|
||||
|
||||
use db::{DeploymentConfig, connect};
|
||||
use clusters::DeploymentConfig;
|
||||
use db::connect_sql;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn Error>> {
|
||||
let config = match env::var_os("BEDROCK_DB_CONFIG") {
|
||||
Some(path) => serde_json::from_slice::<DeploymentConfig>(&fs::read(path)?)?,
|
||||
Some(path) => DeploymentConfig::load(path)?,
|
||||
None => DeploymentConfig::default(),
|
||||
};
|
||||
let db = connect(&config).await?;
|
||||
println!(
|
||||
"Bedrock storage ready ({:?}, revision {}, read-only: {})",
|
||||
db.driver(),
|
||||
db.revision().await?,
|
||||
db.is_read_only()
|
||||
);
|
||||
let resolved = config.resolve()?;
|
||||
for (role, settings) in &resolved.sql {
|
||||
let connection = connect_sql(settings).await?;
|
||||
println!(
|
||||
"Bedrock storage ready (config {}, role {}, {:?}, revision {}, read-only: {})",
|
||||
resolved.config_version,
|
||||
role,
|
||||
connection.driver(),
|
||||
connection.revision().await?,
|
||||
connection.is_read_only(),
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user