feat(core): optimize query resource lifecycle
This commit is contained in:
1 parent
b4bd6c42a7
commit
295b67dd36
29 files changed
+1857
-335
No files matched your search
@@ -179,6 +179,7 @@ pub async fn disconnect_db(
|
||||
if !should_disconnect {
|
||||
return Ok(Json(()));
|
||||
}
|
||||
app.running_queries.cancel_connection(&body.connection_id);
|
||||
app.remove_connection_pools_detached(&body.connection_id).await;
|
||||
app.nacos_registry.drop_connection(&body.connection_id).await;
|
||||
#[cfg(feature = "mq-admin")]
|
||||
|
||||
@@ -15,6 +15,7 @@ pub struct SaveTabRuntimeCacheRequest {
|
||||
pub payload_base64: String,
|
||||
pub row_count: i64,
|
||||
pub column_count: i64,
|
||||
pub owner_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@@ -31,6 +32,9 @@ pub struct LoadTabRuntimeCacheResponse {
|
||||
pub column_count: i64,
|
||||
pub byte_size: i64,
|
||||
pub updated_at: String,
|
||||
pub created_at: i64,
|
||||
pub last_accessed_at: i64,
|
||||
pub owner_id: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn save_tab_runtime_cache(
|
||||
@@ -41,7 +45,7 @@ pub async fn save_tab_runtime_cache(
|
||||
state
|
||||
.app
|
||||
.storage
|
||||
.save_tab_runtime_cache(&req.key, payload, req.row_count, req.column_count)
|
||||
.save_tab_runtime_cache(&req.key, payload, req.row_count, req.column_count, req.owner_id)
|
||||
.await
|
||||
.map_err(AppError::internal)?;
|
||||
Ok(Json(()))
|
||||
@@ -59,9 +63,53 @@ pub async fn load_tab_runtime_cache(
|
||||
column_count: entry.column_count,
|
||||
byte_size: entry.byte_size,
|
||||
updated_at: entry.updated_at,
|
||||
created_at: entry.created_at,
|
||||
last_accessed_at: entry.last_accessed_at,
|
||||
owner_id: entry.owner_id,
|
||||
})))
|
||||
}
|
||||
|
||||
pub async fn list_tab_runtime_cache_metadata(
|
||||
State(state): State<Arc<WebState>>,
|
||||
) -> Result<Json<Vec<dbx_core::storage::TabRuntimeCacheMetadata>>, AppError> {
|
||||
Ok(Json(state.app.storage.list_tab_runtime_cache_metadata().await.map_err(AppError::internal)?))
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PruneTabRuntimeCacheRequest {
|
||||
pub live_keys: Vec<String>,
|
||||
pub max_bytes: i64,
|
||||
pub orphan_grace_ms: i64,
|
||||
pub max_age_ms: Option<i64>,
|
||||
}
|
||||
|
||||
pub async fn prune_tab_runtime_cache(
|
||||
State(state): State<Arc<WebState>>,
|
||||
Json(request): Json<PruneTabRuntimeCacheRequest>,
|
||||
) -> Result<Json<dbx_core::storage::TabRuntimeCachePruneResult>, AppError> {
|
||||
Ok(Json(
|
||||
state
|
||||
.app
|
||||
.storage
|
||||
.prune_tab_runtime_cache(request.live_keys, request.max_bytes, request.orphan_grace_ms, request.max_age_ms)
|
||||
.await
|
||||
.map_err(AppError::internal)?,
|
||||
))
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct TabRuntimeCacheOwnerQuery {
|
||||
pub owner_id: String,
|
||||
}
|
||||
|
||||
pub async fn delete_tab_runtime_cache_owner(
|
||||
State(state): State<Arc<WebState>>,
|
||||
Query(query): Query<TabRuntimeCacheOwnerQuery>,
|
||||
) -> Result<Json<usize>, AppError> {
|
||||
Ok(Json(state.app.storage.delete_tab_runtime_cache_owner(&query.owner_id).await.map_err(AppError::internal)?))
|
||||
}
|
||||
|
||||
pub async fn delete_tab_runtime_cache(
|
||||
State(state): State<Arc<WebState>>,
|
||||
Query(query): Query<TabRuntimeCacheKeyQuery>,
|
||||
|
||||
Reference in new issue
Block a user