Skip to content

Commit 5d52bf4

Browse files
committed
check if running on globe and use globe strategy
1 parent 4cfe7e2 commit 5d52bf4

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/lib.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use sqlite::{
1414
};
1515

1616
use crate::{
17-
auth::GlobeStrategy,
17+
auth::{DbAuthStrategy, EnvVarStrategy, GlobeStrategy},
1818
utils::{
1919
count_parameters, execute_async_task, get_tokio, is_aligned, sql_is_begin_transaction,
2020
sql_is_commit, sql_is_pragma, sql_is_rollback,
@@ -64,10 +64,19 @@ pub unsafe extern "C" fn sqlite3_open_v2(
6464
return SQLITE_CANTOPEN;
6565
}
6666

67-
let connection = get_tokio().block_on(transport::DatabaseConnection::open(
68-
db_name,
69-
Box::new(GlobeStrategy),
70-
));
67+
// Check if running in Globe environment
68+
let auth_strategy: Box<dyn DbAuthStrategy> = {
69+
let is_globe_env = std::env::var("GLOBE")
70+
.and_then(|v| Ok(v == "1"))
71+
.unwrap_or(false);
72+
if is_globe_env {
73+
Box::new(GlobeStrategy)
74+
} else {
75+
Box::new(EnvVarStrategy)
76+
}
77+
};
78+
let connection =
79+
get_tokio().block_on(transport::DatabaseConnection::open(db_name, auth_strategy));
7180
if connection.is_err() {
7281
return SQLITE_CANTOPEN;
7382
}

0 commit comments

Comments
 (0)