mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
refactor: 移除独立 hub/proxy/executor/gateway crate,统一为 gateway tunnel 架构
- 删除 aether-hub、aether-proxy 独立项目及其 Dockerfile/配置 - 删除 crates/aether-executor 和 crates/aether-gateway 全部模块 - 新增 apps/ 目录作为应用入口 - 将 hub 概念重构为 gateway tunnel transport - 将 executor 重构为 execution runtime - 新增 tunnel.rs 合约定义和 testkit tunnel/execution_runtime 模块 - 更新 Python 服务层和测试适配新架构命名
This commit is contained in:
86
crates/aether-testkit/src/tunnel.rs
Normal file
86
crates/aether-testkit/src/tunnel.rs
Normal file
@@ -0,0 +1,86 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use aether_gateway::{
|
||||
build_tunnel_runtime_router_with_state, TunnelConnConfig, TunnelControlPlaneClient,
|
||||
TunnelRuntimeState,
|
||||
};
|
||||
use aether_runtime::DistributedConcurrencyGate;
|
||||
|
||||
use crate::server::SpawnedServer;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TunnelHarnessConfig {
|
||||
pub max_streams: usize,
|
||||
pub ping_interval: Duration,
|
||||
pub idle_timeout: Duration,
|
||||
pub outbound_queue_capacity: usize,
|
||||
pub max_in_flight_requests: Option<usize>,
|
||||
pub distributed_request_gate: Option<DistributedConcurrencyGate>,
|
||||
}
|
||||
|
||||
impl Default for TunnelHarnessConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
max_streams: 128,
|
||||
ping_interval: Duration::from_secs(15),
|
||||
idle_timeout: Duration::ZERO,
|
||||
outbound_queue_capacity: 128,
|
||||
max_in_flight_requests: None,
|
||||
distributed_request_gate: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TunnelHarness {
|
||||
server: SpawnedServer,
|
||||
}
|
||||
|
||||
impl TunnelHarness {
|
||||
pub async fn start(config: TunnelHarnessConfig) -> Result<Self, String> {
|
||||
Self::start_with_server(config, None).await
|
||||
}
|
||||
|
||||
pub async fn start_on_port(config: TunnelHarnessConfig, port: u16) -> Result<Self, String> {
|
||||
Self::start_with_server(config, Some(port)).await
|
||||
}
|
||||
|
||||
async fn start_with_server(
|
||||
config: TunnelHarnessConfig,
|
||||
port: Option<u16>,
|
||||
) -> Result<Self, String> {
|
||||
let state = TunnelRuntimeState::new(
|
||||
TunnelControlPlaneClient::disabled(),
|
||||
TunnelConnConfig {
|
||||
ping_interval: config.ping_interval,
|
||||
idle_timeout: config.idle_timeout,
|
||||
outbound_queue_capacity: config.outbound_queue_capacity,
|
||||
},
|
||||
config.max_streams,
|
||||
)
|
||||
.with_request_concurrency_limit(config.max_in_flight_requests);
|
||||
let state = if let Some(gate) = config.distributed_request_gate {
|
||||
state.with_distributed_request_gate(gate)
|
||||
} else {
|
||||
state
|
||||
};
|
||||
let router = build_tunnel_runtime_router_with_state(state);
|
||||
let server = match port {
|
||||
Some(port) => SpawnedServer::start_on_port(port, router)
|
||||
.await
|
||||
.map_err(|err| format!("failed to start tunnel harness: {err}"))?,
|
||||
None => SpawnedServer::start(router)
|
||||
.await
|
||||
.map_err(|err| format!("failed to start tunnel harness: {err}"))?,
|
||||
};
|
||||
Ok(Self { server })
|
||||
}
|
||||
|
||||
pub fn base_url(&self) -> &str {
|
||||
self.server.base_url()
|
||||
}
|
||||
|
||||
pub fn port(&self) -> u16 {
|
||||
self.server.port()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user