feat(solr): add Apache Solr connection support
This commit is contained in:
1 parent
7b407ccbfc
commit
3687a9cbfb
75 files changed
+5596
-82
No files matched your search
@@ -110,6 +110,7 @@ pub enum PoolKind {
|
||||
SqlServer(Arc<tokio::sync::Mutex<db::sqlserver::SqlServerClient>>),
|
||||
Elasticsearch(db::elasticsearch_driver::EsClient),
|
||||
Easysearch(db::easysearch_driver::EasysearchClient),
|
||||
Solr(db::solr_driver::SolrClient),
|
||||
Meilisearch(db::meilisearch_driver::MeilisearchClient),
|
||||
HBase(db::hbase_driver::HBaseClient),
|
||||
VectorDb(db::vector_driver::VectorClient),
|
||||
@@ -2742,6 +2743,22 @@ impl AppState {
|
||||
db::easysearch_driver::test_connection(&mut client, connect_timeout).await?;
|
||||
PoolKind::Easysearch(client)
|
||||
}
|
||||
DatabaseType::Solr => {
|
||||
let mut client = db::solr_driver::SolrClient::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::solr_driver::test_connection(&mut client, connect_timeout).await?;
|
||||
PoolKind::Solr(client)
|
||||
}
|
||||
DatabaseType::Meilisearch => {
|
||||
let client = db::meilisearch_driver::MeilisearchClient::new_for_config(
|
||||
&url,
|
||||
@@ -4084,6 +4101,17 @@ impl AppState {
|
||||
}
|
||||
}
|
||||
}
|
||||
PoolKind::Solr(client) => {
|
||||
let mut client = client.clone();
|
||||
let timeout = crate::db::connection_timeout();
|
||||
match db::solr_driver::test_connection(&mut client, timeout).await {
|
||||
Ok(()) => false,
|
||||
Err(err) => {
|
||||
log::warn!("Solr connection pool '{pool_key}' is stale: {err}");
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
PoolKind::Meilisearch(client) => {
|
||||
let client = client.clone();
|
||||
let timeout = crate::db::connection_timeout();
|
||||
@@ -5198,6 +5226,16 @@ impl AppState {
|
||||
}
|
||||
}
|
||||
}
|
||||
PoolKind::Solr(client) => {
|
||||
let mut client = client.clone();
|
||||
match db::solr_driver::test_connection(&mut client, timeout).await {
|
||||
Ok(()) => true,
|
||||
Err(e) => {
|
||||
log::warn!("Solr connection pool '{key}' is unhealthy: {e}");
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
PoolKind::Meilisearch(client) => {
|
||||
let client = client.clone();
|
||||
match db::meilisearch_driver::test_connection(&client, timeout).await {
|
||||
@@ -5599,6 +5637,7 @@ enum KeepaliveTarget {
|
||||
SqlServer(Arc<tokio::sync::Mutex<db::sqlserver::SqlServerClient>>),
|
||||
Elasticsearch(db::elasticsearch_driver::EsClient),
|
||||
Easysearch(db::easysearch_driver::EasysearchClient),
|
||||
Solr(db::solr_driver::SolrClient),
|
||||
HBase(db::hbase_driver::HBaseClient),
|
||||
VectorDb(db::vector_driver::VectorClient),
|
||||
InfluxDb(db::influxdb_driver::InfluxdbClient),
|
||||
@@ -5700,6 +5739,7 @@ fn keepalive_target_from_pool(pool: &PoolKind, config: &ConnectionConfig) -> Opt
|
||||
PoolKind::SqlServer(client) => Some(KeepaliveTarget::SqlServer(client.clone())),
|
||||
PoolKind::Elasticsearch(client) => Some(KeepaliveTarget::Elasticsearch(client.clone())),
|
||||
PoolKind::Easysearch(client) => Some(KeepaliveTarget::Easysearch(client.clone())),
|
||||
PoolKind::Solr(client) => Some(KeepaliveTarget::Solr(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())),
|
||||
@@ -5742,6 +5782,7 @@ async fn ping_keepalive_target(target: &mut KeepaliveTarget, timeout: Duration)
|
||||
KeepaliveTarget::Easysearch(client) => {
|
||||
db::easysearch_driver::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::HBase(client) => {
|
||||
db::hbase_driver::test_connection(client, timeout).await.map(|_| ()).map_err(Into::into)
|
||||
}
|
||||
@@ -6162,6 +6203,7 @@ fn clone_pool_kind(pool: &PoolKind) -> PoolKind {
|
||||
PoolKind::SqlServer(client) => PoolKind::SqlServer(client.clone()),
|
||||
PoolKind::Elasticsearch(client) => PoolKind::Elasticsearch(client.clone()),
|
||||
PoolKind::Easysearch(client) => PoolKind::Easysearch(client.clone()),
|
||||
PoolKind::Solr(client) => PoolKind::Solr(client.clone()),
|
||||
PoolKind::Meilisearch(client) => PoolKind::Meilisearch(client.clone()),
|
||||
PoolKind::HBase(client) => PoolKind::HBase(client.clone()),
|
||||
PoolKind::VectorDb(client) => PoolKind::VectorDb(client.clone()),
|
||||
@@ -6221,6 +6263,9 @@ async fn close_pool_kind(pool: PoolKind) -> Result<(), String> {
|
||||
PoolKind::Easysearch(client) => {
|
||||
drop(client);
|
||||
}
|
||||
PoolKind::Solr(client) => {
|
||||
drop(client);
|
||||
}
|
||||
PoolKind::Meilisearch(client) => {
|
||||
drop(client);
|
||||
}
|
||||
@@ -6319,6 +6364,7 @@ fn base_pool_key_for_with_catalog(
|
||||
db_type,
|
||||
DatabaseType::Elasticsearch
|
||||
| DatabaseType::Easysearch
|
||||
| DatabaseType::Solr
|
||||
| DatabaseType::Qdrant
|
||||
| DatabaseType::Milvus
|
||||
| DatabaseType::Weaviate
|
||||
|
||||
Reference in new issue
Block a user