refactor(tunnel): 移除直连tunnel模式,统一使用Hub转发

- 删除 TunnelTransport 及 TunnelManager 相关引用,所有 tunnel 请求统一走 Hub
- 简化 health_scheduler,不再依赖进程内 TunnelManager 状态判断节点在线
- 简化 resolver,移除本地 tunnel miss 判断与多 worker 告警逻辑
- 简化 service 中 tunnel 连通性检测,统一以 DB 状态为准
- 启动/关闭流程移除 hub_enabled 分支,始终初始化 Hub 连接
- Rust 端 RequestMeta.timeout 增加浮点数反序列化支持,Python 端确保发送整数
This commit is contained in:
fawney19
2026-03-02 11:45:30 +08:00
parent 0564893c4f
commit f3b9f42202
9 changed files with 92 additions and 331 deletions

View File

@@ -1,29 +1,9 @@
import pytest
from src.services.proxy_node.hub_config import reset_hub_config_cache
from src.services.proxy_node.hub_transport import HubTunnelTransport
from src.services.proxy_node.tunnel_protocol import Frame, MsgType
from src.services.proxy_node.tunnel_transport import TunnelTransport, create_tunnel_transport
from src.services.proxy_node.tunnel_transport import create_tunnel_transport
def test_create_tunnel_transport_uses_legacy_transport_when_hub_disabled(
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.setenv("DOCKER_CONTAINER", "false")
monkeypatch.setattr("src.services.proxy_node.hub_config.os.path.exists", lambda _: False)
reset_hub_config_cache()
transport = create_tunnel_transport("node-1", timeout=12.0)
assert isinstance(transport, TunnelTransport)
def test_create_tunnel_transport_uses_hub_transport_when_hub_enabled(
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.setenv("DOCKER_CONTAINER", "true")
monkeypatch.setattr("src.services.proxy_node.hub_config.os.path.exists", lambda _: False)
reset_hub_config_cache()
def test_create_tunnel_transport_always_uses_hub_transport() -> None:
transport = create_tunnel_transport("node-1", timeout=12.0)
assert isinstance(transport, HubTunnelTransport)