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:
fawney19
2026-04-05 20:23:16 +08:00
parent cbc811f6ce
commit 763ff03a7b
777 changed files with 42659 additions and 21469 deletions

View File

@@ -1,4 +1,4 @@
use crate::gateway::{AppState, LocalProviderDeleteTaskState};
use crate::{AppState, LocalProviderDeleteTaskState};
use serde_json::json;
pub(crate) fn admin_provider_id_for_keys(request_path: &str) -> Option<String> {

View File

@@ -1,5 +1,5 @@
use crate::gateway::handlers::{json_string_list, unix_secs_to_rfc3339};
use crate::gateway::AppState;
use crate::handlers::{json_string_list, unix_secs_to_rfc3339};
use crate::AppState;
#[cfg(test)]
use aether_crypto::DEVELOPMENT_ENCRYPTION_KEY;
use aether_crypto::{decrypt_python_fernet_ciphertext, encrypt_python_fernet_plaintext};

View File

@@ -190,7 +190,7 @@ pub(crate) struct InternalGatewayExecuteRequest {
#[serde(default)]
pub(crate) body_base64: Option<String>,
#[serde(default)]
pub(crate) auth_context: Option<crate::gateway::GatewayControlAuthContext>,
pub(crate) auth_context: Option<crate::control::GatewayControlAuthContext>,
}
#[derive(Debug, Deserialize)]

View File

@@ -1,10 +1,12 @@
use crate::gateway::constants::{
use crate::constants::{
CONTROL_EXECUTE_FALLBACK_HEADER, TRUSTED_ADMIN_MANAGEMENT_TOKEN_ID_HEADER,
TRUSTED_ADMIN_SESSION_ID_HEADER, TRUSTED_ADMIN_USER_ID_HEADER, TRUSTED_ADMIN_USER_ROLE_HEADER,
};
use crate::gateway::handlers::OFFICIAL_EXTERNAL_MODEL_PROVIDERS;
use crate::gateway::headers::header_value_str;
use crate::gateway::{GatewayControlDecision, GatewayPublicRequestContext};
use crate::control::GatewayControlDecision;
use crate::control::GatewayPublicRequestContext;
use crate::handlers::OFFICIAL_EXTERNAL_MODEL_PROVIDERS;
use crate::headers::header_value_str;
use crate::tunnel::TUNNEL_ROUTE_FAMILY;
use axum::http::{self, HeaderName};
use chrono::{SecondsFormat, Utc};
use url::form_urlencoded;
@@ -347,25 +349,23 @@ pub(crate) fn internal_proxy_local_requires_buffered_body(
decision.route_family.as_deref(),
decision.route_kind.as_deref()
),
(
Some(crate::gateway::TUNNEL_ROUTE_FAMILY),
Some("heartbeat" | "node_status")
) | (
Some("internal_gateway"),
Some(
"resolve"
| "auth_context"
| "decision_sync"
| "decision_stream"
| "execute_sync"
| "execute_stream"
| "plan_sync"
| "plan_stream"
| "report_sync"
| "report_stream"
| "finalize_sync"
(Some(TUNNEL_ROUTE_FAMILY), Some("heartbeat" | "node_status"))
| (
Some("internal_gateway"),
Some(
"resolve"
| "auth_context"
| "decision_sync"
| "decision_stream"
| "execute_sync"
| "execute_stream"
| "plan_sync"
| "plan_stream"
| "report_sync"
| "report_stream"
| "finalize_sync"
)
)
)
)
})
}