feat(duckdb): move support to standalone driver
This commit is contained in:
76 files changed
+5400
-8258
No files matched your search
@@ -5,7 +5,7 @@ use tauri::{Emitter, State};
|
||||
use dbx_core::agent_manager::{AgentDriverInfo, DriverStoreUsage, JavaRuntimeConfig, JavaRuntimeMode, DEFAULT_JRE_KEY};
|
||||
use dbx_core::agent_service::{
|
||||
build_agent_list, clear_agent_download_cache, fetch_registry_from, import_agent_driver,
|
||||
import_agents_from_zip as import_agents_from_zip_core, inspect_offline_zip, install_agent_driver_from,
|
||||
import_agents_from_package as import_agents_from_package_core, inspect_offline_package, install_agent_driver_from,
|
||||
invalidate_registry_cache, reinstall_agent_jre_from, uninstall_agent_driver, uninstall_agent_jre,
|
||||
upgrade_all_agent_drivers_from, AgentProgressEvent, OfflineImportPlan, UpgradeAllAgentDriversResult,
|
||||
};
|
||||
@@ -111,6 +111,7 @@ pub async fn check_agent_update_blockers(
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn uninstall_agent(state: State<'_, Arc<AppState>>, db_type: String) -> Result<(), String> {
|
||||
ensure_no_agent_update_blockers(state.inner().as_ref(), std::slice::from_ref(&db_type)).await?;
|
||||
uninstall_agent_driver(&state.agent_manager, &db_type).await
|
||||
}
|
||||
|
||||
@@ -166,14 +167,15 @@ pub async fn import_agents_from_zip(
|
||||
operation_id: Option<String>,
|
||||
) -> Result<u32, String> {
|
||||
let am = &state.agent_manager;
|
||||
let zip_path = std::path::PathBuf::from(&path);
|
||||
let plan = inspect_offline_zip(&zip_path)?;
|
||||
let package_path = std::path::PathBuf::from(&path);
|
||||
let plan = inspect_offline_package(&package_path)?;
|
||||
ensure_no_offline_import_blockers(state.inner().as_ref(), &plan).await?;
|
||||
let app_handle = app.clone();
|
||||
let operation_id = operation_id.unwrap_or_else(|| uuid::Uuid::new_v4().to_string());
|
||||
let result =
|
||||
import_agents_from_zip_core(am, &zip_path, |event| emit_agent_progress(&app_handle, &operation_id, event))
|
||||
.await?;
|
||||
let result = import_agents_from_package_core(am, &package_path, |event| {
|
||||
emit_agent_progress(&app_handle, &operation_id, event)
|
||||
})
|
||||
.await?;
|
||||
let count = result.drivers_installed.len() as u32;
|
||||
emit_agent_progress(&app, &operation_id, AgentProgressEvent::step("done"));
|
||||
Ok(count)
|
||||
|
||||
@@ -839,13 +839,13 @@ async fn test_connection_with_info_inner(
|
||||
// are reset after both successful and failed Redis tests.
|
||||
test_redis_connection(state, &tunnel_id, &config, &host, port, connect_timeout).await
|
||||
}
|
||||
#[cfg(feature = "duckdb-bundled")]
|
||||
#[cfg(feature = "duckdb-sidecar")]
|
||||
DatabaseType::DuckDb => {
|
||||
state.test_duckdb_connection_config(&config).await?;
|
||||
Ok("Connection successful".to_string())
|
||||
}
|
||||
#[cfg(not(feature = "duckdb-bundled"))]
|
||||
DatabaseType::DuckDb => Err("DuckDB support not compiled (enable duckdb-bundled feature)".to_string()),
|
||||
#[cfg(not(feature = "duckdb-sidecar"))]
|
||||
DatabaseType::DuckDb => Err("DuckDB support is not compiled in this build".to_string()),
|
||||
DatabaseType::MongoDb => {
|
||||
if mongo_uses_legacy_driver(&config) {
|
||||
let am = &state.agent_manager;
|
||||
@@ -1144,22 +1144,10 @@ pub async fn connect_db(
|
||||
};
|
||||
con
|
||||
}
|
||||
#[cfg(feature = "duckdb-bundled")]
|
||||
DatabaseType::DuckDb => {
|
||||
let con = db::duckdb_driver::connect_path(&expand_tilde(&db_config.host))?;
|
||||
{
|
||||
let locked = con.lock().map_err(|e| e.to_string())?;
|
||||
for attached in &db_config.attached_databases {
|
||||
dbx_core::schema::duckdb_attach_database(&locked, &attached.name, &expand_tilde(&attached.path))?;
|
||||
}
|
||||
if let Some(script) = db_config.init_script.as_deref() {
|
||||
db::duckdb_driver::run_init_script(&locked, script)?;
|
||||
}
|
||||
}
|
||||
PoolKind::DuckDb(con)
|
||||
}
|
||||
#[cfg(not(feature = "duckdb-bundled"))]
|
||||
DatabaseType::DuckDb => return Err("DuckDB support not compiled (enable duckdb-bundled feature)".to_string()),
|
||||
#[cfg(feature = "duckdb-sidecar")]
|
||||
DatabaseType::DuckDb => state.create_duckdb_pool(&db_config).await?,
|
||||
#[cfg(not(feature = "duckdb-sidecar"))]
|
||||
DatabaseType::DuckDb => return Err("DuckDB support is not compiled in this build".to_string()),
|
||||
DatabaseType::MongoDb => {
|
||||
if mongo_uses_legacy_driver(&db_config) {
|
||||
let mut client =
|
||||
|
||||
@@ -428,7 +428,7 @@ pub fn build_create_database_sql(options: dbx_core::db_admin_sql::CreateDatabase
|
||||
dbx_core::db_admin_sql::build_create_database_sql(options)
|
||||
}
|
||||
|
||||
#[cfg(feature = "duckdb-bundled")]
|
||||
#[cfg(feature = "duckdb-sidecar")]
|
||||
#[tauri::command]
|
||||
pub fn build_duckdb_attach_database_sql(
|
||||
options: dbx_core::db_admin_sql::DuckDbAttachDatabaseSqlOptions,
|
||||
|
||||
Reference in new issue
Block a user