mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-03 09:50:21 +08:00
refactor: 移除独立 hub/proxy/executor/gateway crate,统一为 gateway tunnel 架构
- 删除 aether-hub、aether-proxy 独立项目及其 Dockerfile/配置 - 删除 crates/aether-executor 和 crates/aether-gateway 全部模块 - 新增 apps/ 目录作为应用入口 - 将 hub 概念重构为 gateway tunnel transport - 将 executor 重构为 execution runtime - 新增 tunnel.rs 合约定义和 testkit tunnel/execution_runtime 模块 - 更新 Python 服务层和测试适配新架构命名
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub(super) struct DbMaintenanceRunSummary {
|
||||
pub(super) attempted: usize,
|
||||
pub(super) succeeded: usize,
|
||||
}
|
||||
|
||||
pub(super) async fn perform_db_maintenance_once(
|
||||
data: &GatewayDataState,
|
||||
) -> Result<DbMaintenanceRunSummary, aether_data::DataLayerError> {
|
||||
let Some(pool) = data.postgres_pool() else {
|
||||
return Ok(DbMaintenanceRunSummary {
|
||||
attempted: 0,
|
||||
succeeded: 0,
|
||||
});
|
||||
};
|
||||
|
||||
run_db_maintenance_with(data, |table_name| {
|
||||
let pool = pool.clone();
|
||||
async move {
|
||||
let statement = format!("VACUUM ANALYZE {table_name}");
|
||||
sqlx::raw_sql(&statement).execute(&pool).await?;
|
||||
Ok(())
|
||||
}
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
pub(super) async fn run_db_maintenance_with<F, Fut>(
|
||||
data: &GatewayDataState,
|
||||
mut vacuum_table: F,
|
||||
) -> Result<DbMaintenanceRunSummary, aether_data::DataLayerError>
|
||||
where
|
||||
F: FnMut(&'static str) -> Fut,
|
||||
Fut: std::future::Future<Output = Result<(), aether_data::DataLayerError>>,
|
||||
{
|
||||
if !system_config_bool(data, "enable_db_maintenance", true).await? {
|
||||
return Ok(DbMaintenanceRunSummary {
|
||||
attempted: 0,
|
||||
succeeded: 0,
|
||||
});
|
||||
}
|
||||
|
||||
let mut summary = DbMaintenanceRunSummary {
|
||||
attempted: 0,
|
||||
succeeded: 0,
|
||||
};
|
||||
for table_name in DB_MAINTENANCE_TABLES {
|
||||
summary.attempted += 1;
|
||||
match vacuum_table(table_name).await {
|
||||
Ok(()) => summary.succeeded += 1,
|
||||
Err(err) => {
|
||||
warn!(table = table_name, error = %err, "gateway db maintenance table failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(summary)
|
||||
}
|
||||
Reference in New Issue
Block a user