mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-08 10:27:46 +08:00
refactor: 拆分 gateway 单体为独立 crate,新增 systemd 部署方案
将 gateway 内部的 model-fetch、provider-transport、scheduler-core、 usage-runtime、video-tasks-core 模块提取为独立 crate;重构 gateway 内部模块结构(state/router/cache/data/query 等);移除大量遗留模块 文件;新增 systemd 二进制部署骨架及相关文档;更新前端 usage 相关 API 和组件。
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use tracing::info;
|
||||
|
||||
use crate::gateway::gateway_data::GatewayDataState;
|
||||
use crate::gateway::{AppState, GatewayError};
|
||||
use crate::data::GatewayDataState;
|
||||
use crate::{AppState, GatewayError};
|
||||
|
||||
use super::{
|
||||
cleanup_audit_logs_once, cleanup_expired_gemini_file_mappings_once,
|
||||
@@ -16,7 +16,13 @@ pub(super) async fn run_audit_cleanup_once(
|
||||
) -> Result<(), aether_data::DataLayerError> {
|
||||
let deleted = cleanup_audit_logs_once(data).await?;
|
||||
if deleted > 0 {
|
||||
info!(deleted, "gateway deleted expired audit logs");
|
||||
info!(
|
||||
event_name = "audit_cleanup_completed",
|
||||
log_type = "ops",
|
||||
worker = "audit_cleanup",
|
||||
deleted,
|
||||
"gateway deleted expired audit logs"
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -26,7 +32,13 @@ pub(super) async fn run_gemini_file_mapping_cleanup_once(
|
||||
) -> Result<(), aether_data::DataLayerError> {
|
||||
let deleted = cleanup_expired_gemini_file_mappings_once(data).await?;
|
||||
if deleted > 0 {
|
||||
info!(deleted, "gateway deleted expired gemini file mappings");
|
||||
info!(
|
||||
event_name = "gemini_file_mapping_cleanup_completed",
|
||||
log_type = "ops",
|
||||
worker = "gemini_file_mapping_cleanup",
|
||||
deleted,
|
||||
"gateway deleted expired gemini file mappings"
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -37,6 +49,9 @@ pub(super) async fn run_db_maintenance_once(
|
||||
let summary = perform_db_maintenance_once(data).await?;
|
||||
if summary.attempted > 0 {
|
||||
info!(
|
||||
event_name = "db_maintenance_completed",
|
||||
log_type = "ops",
|
||||
worker = "db_maintenance",
|
||||
attempted = summary.attempted,
|
||||
succeeded = summary.succeeded,
|
||||
failed = summary.attempted.saturating_sub(summary.succeeded),
|
||||
@@ -51,6 +66,9 @@ pub(super) async fn run_wallet_daily_usage_aggregation_once(
|
||||
) -> Result<(), aether_data::DataLayerError> {
|
||||
let summary = perform_wallet_daily_usage_aggregation_once(data).await?;
|
||||
info!(
|
||||
event_name = "wallet_daily_usage_aggregation_completed",
|
||||
log_type = "ops",
|
||||
worker = "wallet_daily_usage_aggregation",
|
||||
billing_date = %summary.billing_date,
|
||||
billing_timezone = %summary.billing_timezone,
|
||||
wallets = summary.aggregated_wallets,
|
||||
@@ -68,6 +86,9 @@ pub(super) async fn run_stats_aggregation_once(
|
||||
};
|
||||
|
||||
info!(
|
||||
event_name = "stats_daily_aggregation_completed",
|
||||
log_type = "ops",
|
||||
worker = "stats_daily_aggregation",
|
||||
day_start_utc = %summary.day_start_utc,
|
||||
total_requests = summary.total_requests,
|
||||
model_rows = summary.model_rows,
|
||||
@@ -91,6 +112,9 @@ pub(super) async fn run_usage_cleanup_once(
|
||||
|| summary.records_deleted > 0
|
||||
{
|
||||
info!(
|
||||
event_name = "usage_cleanup_completed",
|
||||
log_type = "ops",
|
||||
worker = "usage_cleanup",
|
||||
body_compressed = summary.body_compressed,
|
||||
body_cleaned = summary.body_cleaned,
|
||||
header_cleaned = summary.header_cleaned,
|
||||
@@ -108,6 +132,9 @@ pub(super) fn run_pool_monitor_once(data: &GatewayDataState) {
|
||||
};
|
||||
|
||||
info!(
|
||||
event_name = "postgres_pool_sampled",
|
||||
log_type = "ops",
|
||||
worker = "pool_monitor",
|
||||
checked_out = summary.checked_out,
|
||||
pool_size = summary.pool_size,
|
||||
idle = summary.idle,
|
||||
@@ -123,6 +150,9 @@ pub(super) async fn run_pending_cleanup_once(
|
||||
let summary = cleanup_stale_pending_requests_once(data).await?;
|
||||
if summary.failed > 0 || summary.recovered > 0 {
|
||||
info!(
|
||||
event_name = "pending_cleanup_completed",
|
||||
log_type = "ops",
|
||||
worker = "pending_cleanup",
|
||||
failed = summary.failed,
|
||||
recovered = summary.recovered,
|
||||
"gateway cleaned stale pending and streaming requests"
|
||||
@@ -139,6 +169,9 @@ pub(super) async fn run_stats_hourly_aggregation_once(
|
||||
};
|
||||
|
||||
info!(
|
||||
event_name = "stats_hourly_aggregation_completed",
|
||||
log_type = "ops",
|
||||
worker = "stats_hourly_aggregation",
|
||||
hour_utc = %summary.hour_utc,
|
||||
total_requests = summary.total_requests,
|
||||
user_rows = summary.user_rows,
|
||||
@@ -153,6 +186,9 @@ pub(super) async fn run_provider_checkin_once(state: &AppState) -> Result<(), Ga
|
||||
let summary = perform_provider_checkin_once(state).await?;
|
||||
if summary.attempted > 0 {
|
||||
info!(
|
||||
event_name = "provider_checkin_completed",
|
||||
log_type = "ops",
|
||||
worker = "provider_checkin",
|
||||
attempted = summary.attempted,
|
||||
succeeded = summary.succeeded,
|
||||
failed = summary.failed,
|
||||
|
||||
Reference in New Issue
Block a user