perf(tauri): split schema command registry into crate
This commit is contained in:
1 parent
0be8a38984
commit
1aebef392d
9 files changed
+123
-53
No files matched your search
Generated
+9
@@ -2114,6 +2114,7 @@ dependencies = [
|
|||||||
"dbx-core",
|
"dbx-core",
|
||||||
"dbx-mcp",
|
"dbx-mcp",
|
||||||
"dbx-tauri-consul",
|
"dbx-tauri-consul",
|
||||||
|
"dbx-tauri-schema",
|
||||||
"deadpool-postgres",
|
"deadpool-postgres",
|
||||||
"font-kit",
|
"font-kit",
|
||||||
"futures",
|
"futures",
|
||||||
@@ -2680,6 +2681,14 @@ dependencies = [
|
|||||||
"tauri",
|
"tauri",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dbx-tauri-schema"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"dbx-core",
|
||||||
|
"tauri",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dbx-types"
|
name = "dbx-types"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = ["src-tauri", "crates/dbx-core", "crates/dbx-driver-agent", "crates/dbx-driver-support", "crates/dbx-driver-elasticsearch", "crates/dbx-driver-mongodb", "crates/dbx-driver-mysql", "crates/dbx-driver-postgres", "crates/dbx-driver-redis", "crates/dbx-driver-sqlserver", "crates/dbx-drivers", "crates/dbx-sql", "crates/dbx-sql-core", "crates/dbx-sql-data", "crates/dbx-sql-dialect", "crates/dbx-sql-schema", "crates/dbx-plugin-runtime", "crates/dbx-formats", "crates/dbx-types", "crates/dbx-platform", "crates/dbx-ai-provider", "crates/dbx-web", "crates/dbx-mcp", "crates/dbx-cli", "crates/dbx-sqlite-worker", "crates/dbx-tauri-consul"]
|
members = ["src-tauri", "crates/dbx-core", "crates/dbx-driver-agent", "crates/dbx-driver-support", "crates/dbx-driver-elasticsearch", "crates/dbx-driver-mongodb", "crates/dbx-driver-mysql", "crates/dbx-driver-postgres", "crates/dbx-driver-redis", "crates/dbx-driver-sqlserver", "crates/dbx-drivers", "crates/dbx-sql", "crates/dbx-sql-core", "crates/dbx-sql-data", "crates/dbx-sql-dialect", "crates/dbx-sql-schema", "crates/dbx-plugin-runtime", "crates/dbx-formats", "crates/dbx-types", "crates/dbx-platform", "crates/dbx-ai-provider", "crates/dbx-web", "crates/dbx-mcp", "crates/dbx-cli", "crates/dbx-sqlite-worker", "crates/dbx-tauri-consul", "crates/dbx-tauri-schema"]
|
||||||
exclude = ["vendor/tauri-plugin-updater", "vendor/ctor", "vendor/dirs-sys", "vendor/pageant", "vendor/rumqttc", "vendor/tiberius", "vendor/webview2-com-sys", "vendor/wry"]
|
exclude = ["vendor/tauri-plugin-updater", "vendor/ctor", "vendor/dirs-sys", "vendor/pageant", "vendor/rumqttc", "vendor/tiberius", "vendor/webview2-com-sys", "vendor/wry"]
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
[package]
|
||||||
|
name = "dbx-tauri-schema"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
rust-version = "1.88.0"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
dbx-core = { path = "../dbx-core", default-features = false }
|
||||||
|
tauri = "2.10.3"
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tauri::State;
|
use tauri::State;
|
||||||
|
|
||||||
use crate::commands::connection::AppState;
|
use dbx_core::connection::AppState;
|
||||||
use dbx_core::db;
|
use dbx_core::db;
|
||||||
|
|
||||||
/// Resolve a non-internal catalog for dispatch to the Doris multi-catalog path.
|
/// Resolve a non-internal catalog for dispatch to the Doris multi-catalog path.
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
mod commands;
|
||||||
|
|
||||||
|
macro_rules! define_registry {
|
||||||
|
($($command:ident),+ $(,)?) => {
|
||||||
|
const COMMANDS: &[&str] = &[$(stringify!($command)),+];
|
||||||
|
|
||||||
|
pub fn invoke_handler() -> impl Fn(tauri::ipc::Invoke<tauri::Wry>) -> bool + Send + Sync + 'static {
|
||||||
|
tauri::generate_handler![$(commands::$command),+]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
define_registry![
|
||||||
|
list_databases,
|
||||||
|
list_database_metadata,
|
||||||
|
list_database_storage,
|
||||||
|
list_xugu_tablespaces,
|
||||||
|
get_sqlserver_completion_context,
|
||||||
|
list_doris_catalogs,
|
||||||
|
list_doris_catalog_databases,
|
||||||
|
list_sqlserver_linked_servers,
|
||||||
|
list_sqlserver_linked_server_catalogs,
|
||||||
|
list_sqlserver_linked_server_schemas,
|
||||||
|
list_sqlserver_linked_server_tables,
|
||||||
|
list_tables,
|
||||||
|
get_table_comment,
|
||||||
|
get_mysql_table_auto_increment,
|
||||||
|
list_objects,
|
||||||
|
list_object_statistics,
|
||||||
|
list_completion_objects,
|
||||||
|
completion_assistant_search,
|
||||||
|
get_object_source,
|
||||||
|
get_event_info,
|
||||||
|
get_custom_type_details,
|
||||||
|
list_schemas,
|
||||||
|
list_schema_infos,
|
||||||
|
list_data_types,
|
||||||
|
get_columns,
|
||||||
|
get_plugin_table_metadata,
|
||||||
|
get_all_columns,
|
||||||
|
get_sqlserver_column_metadata,
|
||||||
|
list_indexes,
|
||||||
|
list_reference_key_columns,
|
||||||
|
list_reference_keys,
|
||||||
|
list_foreign_keys,
|
||||||
|
list_triggers,
|
||||||
|
list_constraints,
|
||||||
|
list_partitions,
|
||||||
|
get_table_partition_status,
|
||||||
|
get_table_partitioning,
|
||||||
|
list_invalid_indexes,
|
||||||
|
list_subpartitions,
|
||||||
|
get_table_ddl,
|
||||||
|
list_functions,
|
||||||
|
list_sequences,
|
||||||
|
list_rules,
|
||||||
|
list_owners,
|
||||||
|
get_table_owner,
|
||||||
|
list_extensions,
|
||||||
|
list_available_extensions,
|
||||||
|
list_event_triggers,
|
||||||
|
];
|
||||||
|
|
||||||
|
pub fn handles(command: &str) -> bool {
|
||||||
|
COMMANDS.contains(&command)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn route(
|
||||||
|
main_handler: impl Fn(tauri::ipc::Invoke<tauri::Wry>) -> bool + Send + Sync + 'static,
|
||||||
|
) -> impl Fn(tauri::ipc::Invoke<tauri::Wry>) -> bool + Send + Sync + 'static {
|
||||||
|
let schema_handler = invoke_handler();
|
||||||
|
move |invoke| {
|
||||||
|
if handles(invoke.message.command()) {
|
||||||
|
schema_handler(invoke)
|
||||||
|
} else {
|
||||||
|
main_handler(invoke)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::{handles, COMMANDS};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn handles_only_schema_commands() {
|
||||||
|
assert_eq!(COMMANDS.len(), 48);
|
||||||
|
assert!(handles("list_databases"));
|
||||||
|
assert!(handles("list_event_triggers"));
|
||||||
|
assert!(!handles("prepare_schema_diff"));
|
||||||
|
assert!(!handles("load_connections"));
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-1
@@ -59,6 +59,7 @@ COPY crates/dbx-web/Cargo.toml crates/dbx-web/
|
|||||||
COPY crates/dbx-mcp/Cargo.toml crates/dbx-mcp/
|
COPY crates/dbx-mcp/Cargo.toml crates/dbx-mcp/
|
||||||
COPY crates/dbx-cli/Cargo.toml crates/dbx-cli/
|
COPY crates/dbx-cli/Cargo.toml crates/dbx-cli/
|
||||||
COPY crates/dbx-tauri-consul/Cargo.toml crates/dbx-tauri-consul/
|
COPY crates/dbx-tauri-consul/Cargo.toml crates/dbx-tauri-consul/
|
||||||
|
COPY crates/dbx-tauri-schema/Cargo.toml crates/dbx-tauri-schema/
|
||||||
COPY src-tauri/Cargo.toml src-tauri/
|
COPY src-tauri/Cargo.toml src-tauri/
|
||||||
# Copy every vendored crate: root Cargo.toml [patch.crates-io] points at
|
# Copy every vendored crate: root Cargo.toml [patch.crates-io] points at
|
||||||
# vendor/{ctor,rumqttc,dirs-sys,pageant,wry}; omitting any breaks the offline build.
|
# vendor/{ctor,rumqttc,dirs-sys,pageant,wry}; omitting any breaks the offline build.
|
||||||
@@ -66,7 +67,7 @@ COPY vendor/ vendor/
|
|||||||
RUN for crate in dbx-platform dbx-types dbx-sql dbx-sql-core dbx-sql-data dbx-sql-dialect dbx-sql-schema \
|
RUN for crate in dbx-platform dbx-types dbx-sql dbx-sql-core dbx-sql-data dbx-sql-dialect dbx-sql-schema \
|
||||||
dbx-formats dbx-ai-provider dbx-plugin-runtime dbx-driver-agent dbx-driver-support \
|
dbx-formats dbx-ai-provider dbx-plugin-runtime dbx-driver-agent dbx-driver-support \
|
||||||
dbx-driver-elasticsearch dbx-driver-mongodb dbx-driver-mysql dbx-driver-postgres \
|
dbx-driver-elasticsearch dbx-driver-mongodb dbx-driver-mysql dbx-driver-postgres \
|
||||||
dbx-driver-redis dbx-driver-sqlserver dbx-drivers dbx-sqlite-worker dbx-tauri-consul; do \
|
dbx-driver-redis dbx-driver-sqlserver dbx-drivers dbx-sqlite-worker dbx-tauri-consul dbx-tauri-schema; do \
|
||||||
mkdir -p "crates/$crate/src" && printf "" > "crates/$crate/src/lib.rs"; \
|
mkdir -p "crates/$crate/src" && printf "" > "crates/$crate/src/lib.rs"; \
|
||||||
done \
|
done \
|
||||||
&& echo 'fn main() {}' > crates/dbx-sqlite-worker/src/main.rs
|
&& echo 'fn main() {}' > crates/dbx-sqlite-worker/src/main.rs
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ zip = "4.6.1"
|
|||||||
dbx-core = { path = "../crates/dbx-core", default-features = false }
|
dbx-core = { path = "../crates/dbx-core", default-features = false }
|
||||||
dbx-mcp = { path = "../crates/dbx-mcp", default-features = false, features = ["duckdb-sidecar", "mq-admin"] }
|
dbx-mcp = { path = "../crates/dbx-mcp", default-features = false, features = ["duckdb-sidecar", "mq-admin"] }
|
||||||
dbx-tauri-consul = { path = "../crates/dbx-tauri-consul" }
|
dbx-tauri-consul = { path = "../crates/dbx-tauri-consul" }
|
||||||
|
dbx-tauri-schema = { path = "../crates/dbx-tauri-schema" }
|
||||||
wry = { path = "../vendor/wry" }
|
wry = { path = "../vendor/wry" }
|
||||||
axum = { version = "0.8", features = ["ws"] }
|
axum = { version = "0.8", features = ["ws"] }
|
||||||
font-kit = "0.14.3"
|
font-kit = "0.14.3"
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ pub mod redis_cmd;
|
|||||||
pub mod redis_pubsub_server;
|
pub mod redis_pubsub_server;
|
||||||
pub mod salesforce_oauth;
|
pub mod salesforce_oauth;
|
||||||
pub mod saved_sql;
|
pub mod saved_sql;
|
||||||
pub mod schema;
|
|
||||||
pub mod schema_cache;
|
pub mod schema_cache;
|
||||||
pub mod schema_diff;
|
pub mod schema_diff;
|
||||||
pub mod sql_file;
|
pub mod sql_file;
|
||||||
|
|||||||
+7
-49
@@ -1454,6 +1454,12 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn route_external_commands(
|
||||||
|
main_handler: impl Fn(tauri::ipc::Invoke<tauri::Wry>) -> bool + Send + Sync + 'static,
|
||||||
|
) -> impl Fn(tauri::ipc::Invoke<tauri::Wry>) -> bool + Send + Sync + 'static {
|
||||||
|
dbx_tauri_consul::route(dbx_tauri_schema::route(main_handler))
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
// Metadata/completion command chains nest very large async futures and can
|
// Metadata/completion command chains nest very large async futures and can
|
||||||
@@ -1804,7 +1810,7 @@ pub fn run() {
|
|||||||
request_app_close(app, "settings");
|
request_app_close(app, "settings");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.invoke_handler(migration_gate::guard_handler(dbx_tauri_consul::route(tauri::generate_handler![
|
.invoke_handler(migration_gate::guard_handler(route_external_commands(tauri::generate_handler![
|
||||||
commands::ai::ai_complete,
|
commands::ai::ai_complete,
|
||||||
commands::ai::ai_stream,
|
commands::ai::ai_stream,
|
||||||
commands::ai::ai_agent_stream,
|
commands::ai::ai_agent_stream,
|
||||||
@@ -2000,54 +2006,6 @@ pub fn run() {
|
|||||||
commands::plugins::install_jdbc_plugin,
|
commands::plugins::install_jdbc_plugin,
|
||||||
commands::plugins::install_jdbc_plugin_local,
|
commands::plugins::install_jdbc_plugin_local,
|
||||||
commands::plugins::uninstall_jdbc_plugin,
|
commands::plugins::uninstall_jdbc_plugin,
|
||||||
commands::schema::list_databases,
|
|
||||||
commands::schema::list_database_metadata,
|
|
||||||
commands::schema::list_database_storage,
|
|
||||||
commands::schema::list_xugu_tablespaces,
|
|
||||||
commands::schema::get_sqlserver_completion_context,
|
|
||||||
commands::schema::list_doris_catalogs,
|
|
||||||
commands::schema::list_doris_catalog_databases,
|
|
||||||
commands::schema::list_sqlserver_linked_servers,
|
|
||||||
commands::schema::list_sqlserver_linked_server_catalogs,
|
|
||||||
commands::schema::list_sqlserver_linked_server_schemas,
|
|
||||||
commands::schema::list_sqlserver_linked_server_tables,
|
|
||||||
commands::schema::list_tables,
|
|
||||||
commands::schema::get_table_comment,
|
|
||||||
commands::schema::get_mysql_table_auto_increment,
|
|
||||||
commands::schema::list_objects,
|
|
||||||
commands::schema::list_object_statistics,
|
|
||||||
commands::schema::list_completion_objects,
|
|
||||||
commands::schema::completion_assistant_search,
|
|
||||||
commands::schema::get_object_source,
|
|
||||||
commands::schema::get_event_info,
|
|
||||||
commands::schema::get_custom_type_details,
|
|
||||||
commands::schema::list_schemas,
|
|
||||||
commands::schema::list_schema_infos,
|
|
||||||
commands::schema::list_data_types,
|
|
||||||
commands::schema::get_columns,
|
|
||||||
commands::schema::get_plugin_table_metadata,
|
|
||||||
commands::schema::get_all_columns,
|
|
||||||
commands::schema::get_sqlserver_column_metadata,
|
|
||||||
commands::schema::list_indexes,
|
|
||||||
commands::schema::list_reference_key_columns,
|
|
||||||
commands::schema::list_reference_keys,
|
|
||||||
commands::schema::list_foreign_keys,
|
|
||||||
commands::schema::list_triggers,
|
|
||||||
commands::schema::list_constraints,
|
|
||||||
commands::schema::list_partitions,
|
|
||||||
commands::schema::get_table_partition_status,
|
|
||||||
commands::schema::get_table_partitioning,
|
|
||||||
commands::schema::list_invalid_indexes,
|
|
||||||
commands::schema::list_subpartitions,
|
|
||||||
commands::schema::get_table_ddl,
|
|
||||||
commands::schema::list_functions,
|
|
||||||
commands::schema::list_sequences,
|
|
||||||
commands::schema::list_rules,
|
|
||||||
commands::schema::list_owners,
|
|
||||||
commands::schema::get_table_owner,
|
|
||||||
commands::schema::list_extensions,
|
|
||||||
commands::schema::list_available_extensions,
|
|
||||||
commands::schema::list_event_triggers,
|
|
||||||
commands::schema_diff::prepare_schema_diff,
|
commands::schema_diff::prepare_schema_diff,
|
||||||
commands::schema_diff::generate_schema_sync_sql,
|
commands::schema_diff::generate_schema_sync_sql,
|
||||||
commands::schema_diff::generate_schema_sync_plan,
|
commands::schema_diff::generate_schema_sync_plan,
|
||||||
|
|||||||
Reference in new issue
Block a user