feat: 十轮网关优化 - 安全加固/可观测性/性能/可靠性
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / build (push) Has been cancelled
CI / security-scan (push) Has been cancelled

- SSE Keepalive Ping (15s心跳防止代理断连)
- Timing HTTP 头 (X-Timing-Queue/Inference/Total-Ms)
- Adapter Request-ID 传播到后端
- Session 清理日志回调
- Server 安全加固 (ReadHeaderTimeout/MaxHeaderBytes 防 slowloris)
- Usage Tracker 数据保留清理 (retentionDays + 定期清理)
- Config Reload 后 Adapter Registry 更新 (RegisterIfAbsent + RWMutex)
- Rate Limiter 空闲 Bucket 清理 (30分钟过期)
- Shutdown Drain 超时可配置 (ShutdownDrainSeconds)
- Config 模型字段校验增强 (provider/endpoint/actual_model)
- Auth 过期 Key 自动清理 (5分钟扫描)
- Admin API Rate Limiting
- Adapter Health Check 独立超时 (每个 adapter 3s)
- TCP 连接阶段超时 (DialContext 5s + KeepAlive 30s)
- 幂等键缓存、审计日志、Gzip 中间件、CORS Expose Headers
- Backpressure 响应头、熔断器 Prometheus 指标
- 连接池优化、Trace-ID 全链路传播
This commit is contained in:
selfrelease
2026-08-03 15:43:11 +08:00
parent e7e98271d4
commit da9c8334d8
27 changed files with 3002 additions and 309 deletions
+12 -15
View File
@@ -1,14 +1,18 @@
server:
host: "0.0.0.0"
port: 8080
port: 39000
admin_port: 8081
max_request_body_mb: 20
cors_allowed_origins: ["*"]
auth:
enabled: true
methods: [api_key]
jwt_issuer: edge-ai-gateway
jwt_secret_env: EDGEAI_JWT_SECRET
rate_limit_per_minute: 60
rate_limit_burst: 10
usage_window_minutes: 60
scheduler:
max_running_tasks: 8
@@ -21,9 +25,9 @@ timeouts:
default_connect_ms: 5000
default_queue_ms: 5000
default_first_token_ms: 10000
default_inference_ms: 60000
default_inference_ms: 120000
default_idle_ms: 15000
default_total_ms: 90000
default_total_ms: 180000
cancel_grace_period_ms: 3000
context:
@@ -32,11 +36,14 @@ context:
max_session_messages: 200
session_idle_ttl_minutes: 60
enable_prompt_persistence: false
enable_llm_summary: true
summary_max_tokens: 256
summary_timeout_seconds: 15
models:
general-chat:
provider: ollama
actual_model: deepseek-r1:1.5b
actual_model: qwen2:latest
endpoint: http://127.0.0.1:11434
context_window: 32768
max_output_tokens: 4096
@@ -46,7 +53,7 @@ models:
fast-chat:
provider: ollama
actual_model: deepseek-r1:1.5b
actual_model: qwen2:latest
endpoint: http://127.0.0.1:11434
context_window: 16384
max_output_tokens: 2048
@@ -54,16 +61,6 @@ models:
residency: on_demand
idle_unload_seconds: 600
vllm-chat:
provider: vllm
actual_model: deepseek-r1:1.5b
endpoint: http://127.0.0.1:8000
context_window: 32768
max_output_tokens: 4096
max_concurrency: 4
residency: always
cancel_supported: true
routing:
sensitive_data_local_only: true
allow_cloud_fallback_by_default: false