feat(etcd): add agent-backed etcd support
This commit is contained in:
1 parent
7bd8d29a79
commit
e6062b2b07
49 files changed
+1524
-15
No files matched your search
@@ -181,6 +181,8 @@ mod tests {
|
||||
query_timeout_secs: dbx_core::models::connection::default_query_timeout_secs(),
|
||||
ssl: false,
|
||||
ca_cert_path: String::new(),
|
||||
client_cert_path: String::new(),
|
||||
client_key_path: String::new(),
|
||||
sysdba: false,
|
||||
oracle_connection_type: None,
|
||||
connection_string: None,
|
||||
@@ -191,6 +193,7 @@ mod tests {
|
||||
redis_sentinel_password: String::new(),
|
||||
redis_sentinel_tls: false,
|
||||
redis_cluster_nodes: String::new(),
|
||||
etcd_endpoints: String::new(),
|
||||
external_config: None,
|
||||
jdbc_driver_class: None,
|
||||
jdbc_driver_paths: Vec::new(),
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum::extract::State;
|
||||
use axum::Json;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::error::AppError;
|
||||
use crate::state::WebState;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct EtcdListPrefixRequest {
|
||||
pub connection_id: String,
|
||||
pub prefix: String,
|
||||
pub limit: usize,
|
||||
pub continuation: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct EtcdKeyRequest {
|
||||
pub connection_id: String,
|
||||
pub key: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct EtcdPutRequest {
|
||||
pub connection_id: String,
|
||||
pub key: String,
|
||||
pub value: dbx_core::agent_kv::KvValue,
|
||||
pub lease: Option<i64>,
|
||||
}
|
||||
|
||||
pub async fn list_prefix(
|
||||
State(state): State<Arc<WebState>>,
|
||||
Json(req): Json<EtcdListPrefixRequest>,
|
||||
) -> Result<Json<dbx_core::agent_kv::KvListPrefixResponse>, AppError> {
|
||||
let result = dbx_core::agent_kv::kv_list_prefix_core(
|
||||
&state.app,
|
||||
&req.connection_id,
|
||||
&req.prefix,
|
||||
req.limit,
|
||||
req.continuation.as_deref(),
|
||||
)
|
||||
.await
|
||||
.map_err(AppError)?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
pub async fn get(
|
||||
State(state): State<Arc<WebState>>,
|
||||
Json(req): Json<EtcdKeyRequest>,
|
||||
) -> Result<Json<dbx_core::agent_kv::KvGetResponse>, AppError> {
|
||||
let result = dbx_core::agent_kv::kv_get_core(&state.app, &req.connection_id, &req.key).await.map_err(AppError)?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
pub async fn put(
|
||||
State(state): State<Arc<WebState>>,
|
||||
Json(req): Json<EtcdPutRequest>,
|
||||
) -> Result<Json<dbx_core::agent_kv::KvPutResponse>, AppError> {
|
||||
let result = dbx_core::agent_kv::kv_put_core(&state.app, &req.connection_id, &req.key, req.value, req.lease)
|
||||
.await
|
||||
.map_err(AppError)?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
pub async fn delete(
|
||||
State(state): State<Arc<WebState>>,
|
||||
Json(req): Json<EtcdKeyRequest>,
|
||||
) -> Result<Json<dbx_core::agent_kv::KvDeleteResponse>, AppError> {
|
||||
let result =
|
||||
dbx_core::agent_kv::kv_delete_core(&state.app, &req.connection_id, &req.key).await.map_err(AppError)?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
@@ -4,6 +4,7 @@ pub mod app_settings;
|
||||
pub mod connection;
|
||||
pub mod data_compare;
|
||||
pub mod database_export;
|
||||
pub mod etcd;
|
||||
pub mod history;
|
||||
pub mod jdbc;
|
||||
pub mod layout;
|
||||
|
||||
Reference in new issue
Block a user