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 42654 additions and 21464 deletions
@@ -7,13 +7,15 @@ use super::super::{
refresh_antigravity_provider_quota_locally, refresh_codex_provider_quota_locally,
refresh_kiro_provider_quota_locally,
};
use crate::gateway::handlers::public::build_admin_keys_grouped_by_format_payload;
use crate::gateway::handlers::{
use crate::control::GatewayPublicRequestContext;
use crate::handlers::admin::misc_helpers::attach_admin_audit_response;
use crate::handlers::public::build_admin_keys_grouped_by_format_payload;
use crate::handlers::{
admin_provider_id_for_keys, query_param_value, AdminProviderKeyBatchDeleteRequest,
AdminProviderKeyCreateRequest, AdminProviderKeyUpdateRequest, AdminProviderQuotaRefreshRequest,
OAUTH_ACCOUNT_BLOCK_PREFIX,
};
use crate::gateway::{AppState, GatewayError, GatewayPublicRequestContext};
use crate::{AppState, GatewayError};
use axum::{
body::{Body, Bytes},
http,
@@ -74,7 +76,13 @@ pub(super) async fn maybe_build_local_admin_endpoints_keys_response(
));
};
return Ok(Some(match build_admin_reveal_key_payload(state, &key) {
Ok(payload) => Json(payload).into_response(),
Ok(payload) => attach_admin_audit_response(
Json(payload).into_response(),
"admin_provider_key_revealed",
"reveal_provider_key",
"provider_key",
&key_id,
),
Err(detail) => (
http::StatusCode::BAD_REQUEST,
Json(json!({ "detail": detail })),
@@ -115,7 +123,13 @@ pub(super) async fn maybe_build_local_admin_endpoints_keys_response(
};
return Ok(Some(
match build_admin_export_key_payload(state, &key).await {
Ok(payload) => Json(payload).into_response(),
Ok(payload) => attach_admin_audit_response(
Json(payload).into_response(),
"admin_provider_key_exported",
"export_provider_key",
"provider_key_export",
&key_id,
),
Err(detail) => (
http::StatusCode::BAD_REQUEST,
Json(json!({ "detail": detail })),