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:
fawney19
2026-04-03 14:59:58 +08:00
parent ddf18fed9a
commit 8f26e1a31f
983 changed files with 103098 additions and 105837 deletions

View File

@@ -0,0 +1,152 @@
use std::path::PathBuf;
use clap::Parser;
use tracing::info;
use aether_gateway::{serve_execution_runtime_tcp, serve_execution_runtime_unix};
use aether_runtime::{
init_service_runtime, DistributedConcurrencyGate, RedisDistributedConcurrencyConfig,
ServiceRuntimeConfig,
};
#[derive(Parser, Debug)]
#[command(
name = "execution-runtime-harness",
about = "Internal execution runtime harness for Aether tests"
)]
struct Args {
#[arg(
long,
env = "AETHER_EXECUTION_RUNTIME_TRANSPORT",
default_value = "unix_socket"
)]
transport: String,
#[arg(
long,
env = "AETHER_EXECUTION_RUNTIME_BIND",
default_value = "127.0.0.1:5219"
)]
bind: String,
#[arg(
long,
env = "AETHER_EXECUTION_RUNTIME_UNIX_SOCKET",
default_value = "/tmp/aether-execution-runtime.sock"
)]
unix_socket: PathBuf,
#[arg(long, env = "AETHER_EXECUTION_RUNTIME_MAX_IN_FLIGHT_REQUESTS")]
max_in_flight_requests: Option<usize>,
#[arg(long, env = "AETHER_EXECUTION_RUNTIME_DISTRIBUTED_REQUEST_LIMIT")]
distributed_request_limit: Option<usize>,
#[arg(long, env = "AETHER_EXECUTION_RUNTIME_DISTRIBUTED_REQUEST_REDIS_URL")]
distributed_request_redis_url: Option<String>,
#[arg(
long,
env = "AETHER_EXECUTION_RUNTIME_DISTRIBUTED_REQUEST_REDIS_KEY_PREFIX"
)]
distributed_request_redis_key_prefix: Option<String>,
#[arg(
long,
env = "AETHER_EXECUTION_RUNTIME_DISTRIBUTED_REQUEST_LEASE_TTL_MS",
default_value_t = 30_000
)]
distributed_request_lease_ttl_ms: u64,
#[arg(
long,
env = "AETHER_EXECUTION_RUNTIME_DISTRIBUTED_REQUEST_RENEW_INTERVAL_MS",
default_value_t = 10_000
)]
distributed_request_renew_interval_ms: u64,
#[arg(
long,
env = "AETHER_EXECUTION_RUNTIME_DISTRIBUTED_REQUEST_COMMAND_TIMEOUT_MS",
default_value_t = 1_000
)]
distributed_request_command_timeout_ms: u64,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let _ = rustls::crypto::ring::default_provider().install_default();
init_service_runtime(ServiceRuntimeConfig::new(
"aether-execution-runtime-harness",
"aether_gateway=info",
))?;
let args = Args::parse();
let distributed_request_gate = match args.distributed_request_limit.filter(|limit| *limit > 0) {
Some(limit) => {
let redis_url = args
.distributed_request_redis_url
.as_deref()
.map(str::trim)
.filter(|value| !value.is_empty())
.ok_or_else(|| {
std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"AETHER_EXECUTION_RUNTIME_DISTRIBUTED_REQUEST_REDIS_URL is required when distributed request limit is enabled",
)
})?;
Some(DistributedConcurrencyGate::new_redis(
"execution_runtime_requests_distributed",
limit,
RedisDistributedConcurrencyConfig {
url: redis_url.to_string(),
key_prefix: args
.distributed_request_redis_key_prefix
.as_deref()
.map(str::trim)
.filter(|value| !value.is_empty())
.map(ToOwned::to_owned),
lease_ttl_ms: args.distributed_request_lease_ttl_ms.max(1),
renew_interval_ms: args.distributed_request_renew_interval_ms.max(1),
command_timeout_ms: Some(args.distributed_request_command_timeout_ms.max(1)),
},
)?)
}
None => None,
};
match args.transport.trim().to_ascii_lowercase().as_str() {
"unix_socket" | "unix" | "uds" => {
info!(
socket = %args.unix_socket.display(),
"aether execution-runtime harness started"
);
serve_execution_runtime_unix(
&args.unix_socket,
args.max_in_flight_requests,
distributed_request_gate.clone(),
)
.await?;
}
"tcp" => {
info!(
bind = %args.bind,
max_in_flight_requests = args.max_in_flight_requests.unwrap_or_default(),
distributed_request_limit = args.distributed_request_limit.unwrap_or_default(),
"aether execution-runtime harness started"
);
serve_execution_runtime_tcp(
&args.bind,
args.max_in_flight_requests,
distributed_request_gate,
)
.await?;
}
other => {
return Err(format!("unsupported execution runtime transport: {other}").into());
}
}
Ok(())
}

View File

@@ -0,0 +1,161 @@
use std::net::SocketAddr;
use std::time::Duration;
use aether_gateway::{
build_tunnel_runtime_router_with_state, TunnelConnConfig, TunnelControlPlaneClient,
TunnelRuntimeState,
};
use aether_runtime::{
init_service_runtime, DistributedConcurrencyGate, RedisDistributedConcurrencyConfig,
ServiceRuntimeConfig,
};
use clap::Parser;
use tracing::info;
#[derive(Parser, Debug)]
#[command(
name = "aether-tunnel-runtime-harness",
about = "Standalone tunnel relay harness backed by aether-gateway tunnel runtime"
)]
struct Args {
#[arg(
long,
default_value = "0.0.0.0:8085",
env = "AETHER_TUNNEL_STANDALONE_BIND"
)]
bind: String,
#[arg(
long,
default_value_t = 0,
env = "AETHER_TUNNEL_STANDALONE_PROXY_IDLE_TIMEOUT"
)]
proxy_idle_timeout: u64,
#[arg(
long,
default_value_t = 15,
env = "AETHER_TUNNEL_STANDALONE_PING_INTERVAL"
)]
ping_interval: u64,
#[arg(
long,
default_value_t = 2048,
env = "AETHER_TUNNEL_STANDALONE_MAX_STREAMS"
)]
max_streams: usize,
#[arg(
long,
default_value_t = 128,
env = "AETHER_TUNNEL_STANDALONE_OUTBOUND_QUEUE_CAPACITY"
)]
outbound_queue_capacity: usize,
#[arg(
long,
default_value = "http://127.0.0.1:8084",
env = "AETHER_TUNNEL_STANDALONE_APP_BASE_URL"
)]
app_base_url: String,
#[arg(long, env = "AETHER_TUNNEL_STANDALONE_MAX_IN_FLIGHT_REQUESTS")]
max_in_flight_requests: Option<usize>,
#[arg(long, env = "AETHER_TUNNEL_STANDALONE_DISTRIBUTED_REQUEST_LIMIT")]
distributed_request_limit: Option<usize>,
#[arg(long, env = "AETHER_TUNNEL_STANDALONE_DISTRIBUTED_REQUEST_REDIS_URL")]
distributed_request_redis_url: Option<String>,
#[arg(
long,
env = "AETHER_TUNNEL_STANDALONE_DISTRIBUTED_REQUEST_REDIS_KEY_PREFIX"
)]
distributed_request_redis_key_prefix: Option<String>,
#[arg(
long,
env = "AETHER_TUNNEL_STANDALONE_DISTRIBUTED_REQUEST_LEASE_TTL_MS",
default_value_t = 30_000
)]
distributed_request_lease_ttl_ms: u64,
#[arg(
long,
env = "AETHER_TUNNEL_STANDALONE_DISTRIBUTED_REQUEST_RENEW_INTERVAL_MS",
default_value_t = 10_000
)]
distributed_request_renew_interval_ms: u64,
#[arg(
long,
env = "AETHER_TUNNEL_STANDALONE_DISTRIBUTED_REQUEST_COMMAND_TIMEOUT_MS",
default_value_t = 1_000
)]
distributed_request_command_timeout_ms: u64,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
init_service_runtime(ServiceRuntimeConfig::new(
"aether-tunnel-standalone",
"aether_gateway=info",
))?;
let args = Args::parse();
let outbound_queue_capacity = args.outbound_queue_capacity.clamp(8, 4096);
let ping_interval = Duration::from_secs(args.ping_interval);
let mut state = TunnelRuntimeState::new(
TunnelControlPlaneClient::new(args.app_base_url),
TunnelConnConfig {
ping_interval,
idle_timeout: Duration::from_secs(args.proxy_idle_timeout),
outbound_queue_capacity,
},
args.max_streams,
)
.with_request_concurrency_limit(args.max_in_flight_requests);
if let Some(limit) = args.distributed_request_limit.filter(|limit| *limit > 0) {
let redis_url = args
.distributed_request_redis_url
.as_deref()
.map(str::trim)
.filter(|value| !value.is_empty())
.ok_or_else(|| {
std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"AETHER_TUNNEL_STANDALONE_DISTRIBUTED_REQUEST_REDIS_URL is required when distributed request limit is enabled",
)
})?;
state = state.with_distributed_request_gate(DistributedConcurrencyGate::new_redis(
"tunnel_requests_distributed",
limit,
RedisDistributedConcurrencyConfig {
url: redis_url.to_string(),
key_prefix: args
.distributed_request_redis_key_prefix
.as_deref()
.map(str::trim)
.filter(|value| !value.is_empty())
.map(ToOwned::to_owned),
lease_ttl_ms: args.distributed_request_lease_ttl_ms.max(1),
renew_interval_ms: args.distributed_request_renew_interval_ms.max(1),
command_timeout_ms: Some(args.distributed_request_command_timeout_ms.max(1)),
},
)?);
}
let app = build_tunnel_runtime_router_with_state(state);
let listener = tokio::net::TcpListener::bind(&args.bind).await?;
info!(bind = %args.bind, "tunnel runtime harness started");
axum::serve(
listener,
app.into_make_service_with_connect_info::<SocketAddr>(),
)
.await?;
Ok(())
}