perf(agent): reuse daemon process for test_connection to avoid JVM cold start

Keep a per-db-type daemon agent process alive in AgentManager. test_connection
now reuses the warm daemon instead of spawning a new JVM each time. If the
daemon dies, it auto-respawns on next call.
This commit is contained in:
t8y2
2026-05-13 05:08:55 +08:00
parent bc687cee7f
commit a450405b0d
2 changed files with 51 additions and 4 deletions
+4 -3
View File
@@ -113,9 +113,10 @@ pub async fn test_connection(state: State<'_, Arc<AppState>>, config: Connection
db::elasticsearch_driver::test_connection(&client).await.map(|_| "Connection successful".to_string())
}
DatabaseType::Dameng | DatabaseType::Kingbase | DatabaseType::Vastbase | DatabaseType::Goldendb => {
let mut client = state.agent_manager.spawn(&config.db_type).await?;
client
.call::<serde_json::Value>(
state
.agent_manager
.call_daemon::<serde_json::Value>(
&config.db_type,
"test_connection",
serde_json::json!({
"host": host,