feat(couchdb): add Apache CouchDB support
This commit is contained in:
1 parent
508fd00776
commit
eafde81af1
46 files changed
+1248
-38
No files matched your search
@@ -603,6 +603,35 @@
|
||||
"driverManagement": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"dbType": "couchdb",
|
||||
"label": "Apache CouchDB",
|
||||
"runtimeMode": "native",
|
||||
"mcpMode": "bridge",
|
||||
"singleConnectionPool": false,
|
||||
"metadataConnectionScoped": false,
|
||||
"skipTcpProbe": false,
|
||||
"defaultPort": 5984,
|
||||
"supportLevel": "browse",
|
||||
"capabilities": {
|
||||
"queryExecution": true,
|
||||
"metadataBrowse": true,
|
||||
"objectBrowser": false,
|
||||
"objectSource": false,
|
||||
"schemaSearch": false,
|
||||
"diagram": false,
|
||||
"tableDataEdit": false,
|
||||
"tableStructureEdit": false,
|
||||
"tableImport": false,
|
||||
"dataTransfer": false,
|
||||
"sqlFileExecution": false,
|
||||
"databaseCreate": false,
|
||||
"fieldLineage": false,
|
||||
"sqlExplain": false,
|
||||
"userAdmin": false,
|
||||
"driverManagement": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"dbType": "hbase",
|
||||
"label": "Apache HBase",
|
||||
|
||||
@@ -119,6 +119,7 @@ pub enum PoolKind {
|
||||
Elasticsearch(db::elasticsearch_driver::EsClient),
|
||||
Easysearch(db::easysearch_driver::EasysearchClient),
|
||||
Solr(db::solr_driver::SolrClient),
|
||||
CouchDb(db::couchdb_driver::CouchDbClient),
|
||||
Meilisearch(db::meilisearch_driver::MeilisearchClient),
|
||||
Salesforce(db::salesforce_driver::SfClient),
|
||||
HBase(db::hbase_driver::HBaseClient),
|
||||
@@ -3020,6 +3021,22 @@ impl AppState {
|
||||
db::solr_driver::test_connection(&mut client, connect_timeout).await?;
|
||||
PoolKind::Solr(client)
|
||||
}
|
||||
DatabaseType::CouchDb => {
|
||||
let client = db::couchdb_driver::CouchDbClient::from_config(
|
||||
&url,
|
||||
Some(&db_config.username),
|
||||
Some(&db_config.password),
|
||||
db_config.ssl,
|
||||
db_config.url_params.as_deref(),
|
||||
db_config.external_config.as_ref(),
|
||||
connect_timeout,
|
||||
Some(db_config.ca_cert_path.as_str()),
|
||||
Some(db_config.client_cert_path.as_str()),
|
||||
Some(db_config.client_key_path.as_str()),
|
||||
)?;
|
||||
db::couchdb_driver::test_connection(&client, connect_timeout).await?;
|
||||
PoolKind::CouchDb(client)
|
||||
}
|
||||
DatabaseType::Meilisearch => {
|
||||
let client = db::meilisearch_driver::MeilisearchClient::new_for_config(
|
||||
&url,
|
||||
@@ -4455,6 +4472,17 @@ impl AppState {
|
||||
}
|
||||
}
|
||||
}
|
||||
PoolKind::CouchDb(client) => {
|
||||
let client = client.clone();
|
||||
let timeout = crate::db::connection_timeout();
|
||||
match db::couchdb_driver::test_connection(&client, timeout).await {
|
||||
Ok(()) => false,
|
||||
Err(err) => {
|
||||
log::warn!("CouchDB connection pool '{pool_key}' is stale: {err}");
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
PoolKind::Meilisearch(client) => {
|
||||
let client = client.clone();
|
||||
let timeout = crate::db::connection_timeout();
|
||||
@@ -5692,6 +5720,16 @@ impl AppState {
|
||||
}
|
||||
}
|
||||
}
|
||||
PoolKind::CouchDb(client) => {
|
||||
let client = client.clone();
|
||||
match db::couchdb_driver::test_connection(&client, timeout).await {
|
||||
Ok(()) => true,
|
||||
Err(e) => {
|
||||
log::warn!("CouchDB connection pool '{key}' is unhealthy: {e}");
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
PoolKind::Meilisearch(client) => {
|
||||
let client = client.clone();
|
||||
match db::meilisearch_driver::test_connection(&client, timeout).await {
|
||||
@@ -6105,6 +6143,7 @@ enum KeepaliveTarget {
|
||||
Easysearch(db::easysearch_driver::EasysearchClient),
|
||||
Salesforce(db::salesforce_driver::SfClient),
|
||||
Solr(db::solr_driver::SolrClient),
|
||||
CouchDb(db::couchdb_driver::CouchDbClient),
|
||||
HBase(db::hbase_driver::HBaseClient),
|
||||
VectorDb(db::vector_driver::VectorClient),
|
||||
InfluxDb(db::influxdb_driver::InfluxdbClient),
|
||||
@@ -6264,6 +6303,7 @@ fn keepalive_target_from_pool(pool: &PoolKind, config: &ConnectionConfig) -> Opt
|
||||
PoolKind::Easysearch(client) => Some(KeepaliveTarget::Easysearch(client.clone())),
|
||||
PoolKind::Salesforce(client) => Some(KeepaliveTarget::Salesforce(client.clone())),
|
||||
PoolKind::Solr(client) => Some(KeepaliveTarget::Solr(client.clone())),
|
||||
PoolKind::CouchDb(client) => Some(KeepaliveTarget::CouchDb(client.clone())),
|
||||
PoolKind::HBase(client) => Some(KeepaliveTarget::HBase(client.clone())),
|
||||
PoolKind::VectorDb(client) => Some(KeepaliveTarget::VectorDb(client.clone())),
|
||||
PoolKind::InfluxDb(client) => Some(KeepaliveTarget::InfluxDb(client.clone())),
|
||||
@@ -6316,6 +6356,9 @@ async fn ping_keepalive_target(target: &mut KeepaliveTarget, timeout: Duration)
|
||||
db::salesforce_driver::SfClient::test_connection(client, timeout).await.map_err(Into::into)
|
||||
}
|
||||
KeepaliveTarget::Solr(client) => db::solr_driver::test_connection(client, timeout).await.map_err(Into::into),
|
||||
KeepaliveTarget::CouchDb(client) => {
|
||||
db::couchdb_driver::test_connection(client, timeout).await.map_err(Into::into)
|
||||
}
|
||||
KeepaliveTarget::HBase(client) => {
|
||||
db::hbase_driver::test_connection(client, timeout).await.map(|_| ()).map_err(Into::into)
|
||||
}
|
||||
@@ -6768,6 +6811,7 @@ fn clone_pool_kind(pool: &PoolKind) -> PoolKind {
|
||||
PoolKind::Elasticsearch(client) => PoolKind::Elasticsearch(client.clone()),
|
||||
PoolKind::Easysearch(client) => PoolKind::Easysearch(client.clone()),
|
||||
PoolKind::Solr(client) => PoolKind::Solr(client.clone()),
|
||||
PoolKind::CouchDb(client) => PoolKind::CouchDb(client.clone()),
|
||||
PoolKind::Meilisearch(client) => PoolKind::Meilisearch(client.clone()),
|
||||
PoolKind::Salesforce(client) => PoolKind::Salesforce(client.clone()),
|
||||
PoolKind::HBase(client) => PoolKind::HBase(client.clone()),
|
||||
@@ -6831,6 +6875,9 @@ async fn close_pool_kind(pool: PoolKind) -> Result<(), String> {
|
||||
PoolKind::Solr(client) => {
|
||||
drop(client);
|
||||
}
|
||||
PoolKind::CouchDb(client) => {
|
||||
drop(client);
|
||||
}
|
||||
PoolKind::Meilisearch(client) => {
|
||||
drop(client);
|
||||
}
|
||||
@@ -6962,6 +7009,7 @@ fn base_pool_key_for_with_catalog(
|
||||
DatabaseType::Elasticsearch
|
||||
| DatabaseType::Easysearch
|
||||
| DatabaseType::Solr
|
||||
| DatabaseType::CouchDb
|
||||
| DatabaseType::Qdrant
|
||||
| DatabaseType::Milvus
|
||||
| DatabaseType::Weaviate
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
use crate::connection::{AppState, PoolKind};
|
||||
use crate::db::agent_driver::mongo_document_id_params;
|
||||
use crate::db::document_result::DocumentQueryResult;
|
||||
use crate::db::{dynamodb_driver, easysearch_driver, elasticsearch_driver, mongo_driver, solr_driver, vector_driver};
|
||||
use crate::db::{
|
||||
couchdb_driver, dynamodb_driver, easysearch_driver, elasticsearch_driver, mongo_driver, solr_driver, vector_driver,
|
||||
};
|
||||
|
||||
pub use crate::db::vector_driver::CollectionInfo;
|
||||
|
||||
@@ -62,6 +64,7 @@ pub async fn list_databases_core(state: &AppState, connection_id: &str) -> Resul
|
||||
PoolKind::Elasticsearch(_) => Ok(vec!["default".to_string()]),
|
||||
PoolKind::Easysearch(_) => Ok(vec!["default".to_string()]),
|
||||
PoolKind::Solr(_) => Ok(vec!["default".to_string()]),
|
||||
PoolKind::CouchDb(_) => Ok(vec!["default".to_string()]),
|
||||
PoolKind::Meilisearch(_) => Ok(vec!["default".to_string()]),
|
||||
PoolKind::VectorDb(client) => vector_driver::list_databases(client).await,
|
||||
PoolKind::Agent(client) => {
|
||||
@@ -283,6 +286,18 @@ pub async fn list_collections_core(
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
PoolKind::CouchDb(client) => {
|
||||
let names = sort_names(couchdb_driver::list_databases(client).await?);
|
||||
Ok(names
|
||||
.into_iter()
|
||||
.map(|n| CollectionInfo {
|
||||
name: n.clone(),
|
||||
id: n,
|
||||
kind: Some("database".to_string()),
|
||||
..Default::default()
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
PoolKind::Meilisearch(client) => {
|
||||
let names = sort_names(crate::db::meilisearch_driver::list_indexes(client).await?);
|
||||
Ok(names.into_iter().map(|n| CollectionInfo { name: n.clone(), id: n, ..Default::default() }).collect())
|
||||
@@ -481,6 +496,15 @@ pub async fn find_documents_core(
|
||||
solr_driver::find_documents(&client, collection, skip, limit, filter, sort).await
|
||||
}
|
||||
}
|
||||
PoolKind::CouchDb(client) => {
|
||||
let client = client.clone();
|
||||
let _ = projection;
|
||||
if cursor_pagination {
|
||||
couchdb_driver::find_documents_with_cursor(&client, collection, limit, filter, sort, cursor).await
|
||||
} else {
|
||||
couchdb_driver::find_documents(&client, collection, skip, limit, filter, sort).await
|
||||
}
|
||||
}
|
||||
PoolKind::Meilisearch(client) => {
|
||||
let client = client.clone();
|
||||
crate::db::meilisearch_driver::find_documents(&client, collection, skip, limit, filter, sort).await
|
||||
@@ -543,6 +567,10 @@ pub async fn count_document_store_documents_core(
|
||||
let client = client.clone();
|
||||
solr_driver::count_documents(&client, collection, filter).await
|
||||
}
|
||||
PoolKind::CouchDb(client) => {
|
||||
let client = client.clone();
|
||||
couchdb_driver::count_documents(&client, collection, filter).await
|
||||
}
|
||||
_ => Err("Document count is not supported for this connection".to_string()),
|
||||
}
|
||||
}
|
||||
@@ -674,6 +702,11 @@ pub async fn insert_document_core(
|
||||
let _ = routing;
|
||||
solr_driver::insert_document(&client, collection, doc_json).await
|
||||
}
|
||||
PoolKind::CouchDb(client) => {
|
||||
let client = client.clone();
|
||||
let _ = routing;
|
||||
couchdb_driver::insert_document(&client, collection, doc_json).await
|
||||
}
|
||||
PoolKind::Meilisearch(client) => {
|
||||
let client = client.clone();
|
||||
crate::db::meilisearch_driver::insert_document(&client, collection, doc_json).await
|
||||
@@ -743,6 +776,11 @@ pub async fn update_document_core(
|
||||
let _ = routing;
|
||||
solr_driver::update_document(&client, collection, id, doc_json).await
|
||||
}
|
||||
PoolKind::CouchDb(client) => {
|
||||
let client = client.clone();
|
||||
let _ = routing;
|
||||
couchdb_driver::update_document(&client, collection, id, doc_json).await
|
||||
}
|
||||
PoolKind::Meilisearch(client) => {
|
||||
let client = client.clone();
|
||||
crate::db::meilisearch_driver::update_document(&client, collection, id, doc_json).await
|
||||
@@ -806,6 +844,11 @@ pub async fn delete_document_core_with_type(
|
||||
let _ = (document_type, routing);
|
||||
solr_driver::delete_document(&client, collection, id).await
|
||||
}
|
||||
PoolKind::CouchDb(client) => {
|
||||
let client = client.clone();
|
||||
let _ = (document_type, routing);
|
||||
couchdb_driver::delete_document(&client, collection, id).await
|
||||
}
|
||||
PoolKind::Meilisearch(client) => {
|
||||
let client = client.clone();
|
||||
crate::db::meilisearch_driver::delete_document(&client, collection, id).await
|
||||
|
||||
@@ -2063,6 +2063,19 @@ async fn do_execute_typed(
|
||||
}
|
||||
result
|
||||
}
|
||||
PoolKind::CouchDb(client) => {
|
||||
let client = client.clone();
|
||||
let sql = sql.to_string();
|
||||
let max_rows = options.max_rows;
|
||||
let result =
|
||||
wait_for_query_opt(cancel_token, query_timeout, db::couchdb_driver::execute_rest_query(&client, &sql))
|
||||
.await
|
||||
.map(|result| truncate_result_with_max_rows(result, max_rows));
|
||||
if matches!(result.as_ref(), Err(err) if should_discard_pool_after_error(pool_db_type, err)) {
|
||||
state.remove_pool_by_key(pool_key).await;
|
||||
}
|
||||
result
|
||||
}
|
||||
PoolKind::Meilisearch(client) => {
|
||||
let client = client.clone();
|
||||
let sql = sql.to_string();
|
||||
@@ -3125,6 +3138,11 @@ pub async fn close_query_session(
|
||||
db::solr_driver::close_cursor(&client, session_id).await?;
|
||||
Ok(true)
|
||||
}
|
||||
PoolKind::CouchDb(client) => {
|
||||
let client = client.clone();
|
||||
db::couchdb_driver::close_cursor(&client, session_id).await?;
|
||||
Ok(true)
|
||||
}
|
||||
_ => Ok(false),
|
||||
}
|
||||
}
|
||||
@@ -4735,6 +4753,7 @@ fn pool_kind_has_transactional_path(pool: &PoolKind) -> bool {
|
||||
| PoolKind::Elasticsearch(_)
|
||||
| PoolKind::Easysearch(_)
|
||||
| PoolKind::Solr(_)
|
||||
| PoolKind::CouchDb(_)
|
||||
| PoolKind::Meilisearch(_)
|
||||
| PoolKind::Salesforce(_)
|
||||
| PoolKind::VectorDb(_)
|
||||
@@ -5140,6 +5159,7 @@ fn batch_transaction_path(pool: &PoolKind) -> BatchTransactionPath {
|
||||
| PoolKind::Elasticsearch(_)
|
||||
| PoolKind::Easysearch(_)
|
||||
| PoolKind::Solr(_)
|
||||
| PoolKind::CouchDb(_)
|
||||
| PoolKind::Meilisearch(_)
|
||||
| PoolKind::Salesforce(_)
|
||||
| PoolKind::VectorDb(_)
|
||||
|
||||
@@ -8130,6 +8130,9 @@ async fn get_columns_core_for_session_inner_with_pool(
|
||||
PoolKind::Easysearch(client) => {
|
||||
db::easysearch_driver::get_columns(client, table).await.map(deduplicate_column_infos)
|
||||
}
|
||||
PoolKind::CouchDb(client) => {
|
||||
db::couchdb_driver::get_columns(client, table).await.map(deduplicate_column_infos)
|
||||
}
|
||||
PoolKind::Meilisearch(client) => {
|
||||
db::meilisearch_driver::get_columns(client, table).await.map(deduplicate_column_infos)
|
||||
}
|
||||
|
||||
@@ -67,6 +67,9 @@ pub(in crate::schema) async fn list_tables(
|
||||
PoolKind::Solr(client) => {
|
||||
db::solr_driver::list_cores(client).await.map(|names| collection_names_to_tables(names, "CORE"))
|
||||
}
|
||||
PoolKind::CouchDb(client) => {
|
||||
db::couchdb_driver::list_databases(client).await.map(|names| collection_names_to_tables(names, "DATABASE"))
|
||||
}
|
||||
PoolKind::Meilisearch(client) => {
|
||||
db::meilisearch_driver::list_indexes(client).await.map(|names| collection_names_to_tables(names, "INDEX"))
|
||||
}
|
||||
@@ -162,6 +165,7 @@ pub(in crate::schema) async fn get_columns(
|
||||
PoolKind::Elasticsearch(client) => db::elasticsearch_driver::get_columns(client, table).await,
|
||||
PoolKind::Easysearch(client) => db::easysearch_driver::get_columns(client, table).await,
|
||||
PoolKind::Solr(client) => db::solr_driver::get_columns(client, table).await,
|
||||
PoolKind::CouchDb(client) => db::couchdb_driver::get_columns(client, table).await,
|
||||
PoolKind::Meilisearch(client) => db::meilisearch_driver::get_columns(client, table).await,
|
||||
PoolKind::HBase(client) => db::hbase_driver::get_columns(client, database, table).await,
|
||||
PoolKind::VectorDb(_) => Ok(vec![]),
|
||||
|
||||
Reference in new issue
Block a user