mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-03 09:50:21 +08:00
feat(tunnel): 引入 aether-hub 帧路由器,支持多 worker 共享 tunnel 连接
新增 Rust 实现的 aether-hub 服务,作为 Docker 容器内部 WebSocket 帧路由器, 解决多 Gunicorn worker 进程间 tunnel 连接隔离问题。 主要改动: - 新增 aether-hub Rust 项目,实现 proxy/worker 双向帧路由与 stream_id 重映射 - 新增 HubConnectionManager/HubTunnelTransport,worker 通过 Hub 转发 tunnel 帧 - 新增 create_tunnel_transport 工厂函数,按运行环境自动选择 Hub 或直连模式 - 新增 NODE_STATUS 广播机制,Hub 实时通知所有 worker 节点连接状态变化 - CI/CD 新增 build-hub job,Dockerfile 集成 Hub 二进制,deploy.sh 适配 Hub 构建 - 默认 GUNICORN_WORKERS 从 4 降为 2
This commit is contained in:
@@ -495,7 +495,7 @@ class HTTPClientPool:
|
||||
调用方不应关闭此 client,其生命周期由 HTTPClientPool 管理。
|
||||
当 timeout 非 None 时(流式请求),每次创建新 client,由调用方负责关闭。
|
||||
"""
|
||||
from src.services.proxy_node.tunnel_transport import TunnelTransport
|
||||
from src.services.proxy_node.tunnel_transport import create_tunnel_transport
|
||||
|
||||
t = timeout or httpx.Timeout(
|
||||
connect=config.http_connect_timeout,
|
||||
@@ -507,7 +507,7 @@ class HTTPClientPool:
|
||||
|
||||
# 流式请求:每次创建新 client(调用方负责关闭)
|
||||
if timeout is not None:
|
||||
transport = TunnelTransport(node_id, timeout=timeout_secs or 60.0)
|
||||
transport = create_tunnel_transport(node_id, timeout=timeout_secs or 60.0)
|
||||
return httpx.AsyncClient(transport=transport, timeout=t)
|
||||
|
||||
# 非流式请求:复用缓存的 client(加锁与 proxy_clients 保持一致)
|
||||
@@ -517,7 +517,7 @@ class HTTPClientPool:
|
||||
if existing and not existing.is_closed:
|
||||
return existing
|
||||
|
||||
transport = TunnelTransport(node_id, timeout=timeout_secs or 60.0)
|
||||
transport = create_tunnel_transport(node_id, timeout=timeout_secs or 60.0)
|
||||
client = httpx.AsyncClient(transport=transport, timeout=t)
|
||||
cls._tunnel_clients[node_id] = client
|
||||
return client
|
||||
|
||||
Reference in New Issue
Block a user