use chronon_core::Result;
use crate::PostgresSchedulerStore;
#[must_use]
pub fn postgres_test_url() -> String {
std::env::var("CHRONON_POSTGRES_URL")
.or_else(|_| std::env::var("CHRONON_TEST_POSTGRES_URL"))
.unwrap_or_else(|_| "postgres://localhost/chronon_test".into())
}
pub async fn postgres_store_from_env() -> Result<PostgresSchedulerStore> {
let url = postgres_test_url();
if let Ok(schema) = std::env::var("CHRONON_POSTGRES_SCHEMA") {
if std::env::var("CHRONON_POSTGRES_SKIP_BOOTSTRAP").is_ok() {
PostgresSchedulerStore::attach_isolated(&url, &schema).await
} else {
PostgresSchedulerStore::connect_isolated(&url, &schema).await
}
} else {
PostgresSchedulerStore::connect(&url).await
}
}