mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-05 00:47:48 +08:00
fix(runtime-state): govern redis connections
This commit is contained in:
@@ -104,9 +104,16 @@ fn runtime_state_owns_redis_runtime_boundaries() {
|
||||
let mut violations = Vec::new();
|
||||
for root in [
|
||||
"apps/aether-gateway/src",
|
||||
"apps/aether-tunnel/src",
|
||||
"crates/aether-admin/src",
|
||||
"crates/aether-billing/src",
|
||||
"crates/aether-model-fetch/src",
|
||||
"crates/aether-provider-pool/src",
|
||||
"crates/aether-runtime/src",
|
||||
"crates/aether-task-runtime/src",
|
||||
"crates/aether-usage-runtime/src",
|
||||
"crates/aether-provider-transport/src",
|
||||
"crates/aether-wallet/src",
|
||||
] {
|
||||
for path in collect_workspace_rust_files(root) {
|
||||
if path
|
||||
@@ -132,6 +139,33 @@ fn runtime_state_owns_redis_runtime_boundaries() {
|
||||
violations.join("\n")
|
||||
);
|
||||
|
||||
let mut dependency_violations = Vec::new();
|
||||
for manifest in [
|
||||
"apps/aether-gateway/Cargo.toml",
|
||||
"apps/aether-tunnel/Cargo.toml",
|
||||
"crates/aether-admin/Cargo.toml",
|
||||
"crates/aether-billing/Cargo.toml",
|
||||
"crates/aether-model-fetch/Cargo.toml",
|
||||
"crates/aether-provider-pool/Cargo.toml",
|
||||
"crates/aether-provider-transport/Cargo.toml",
|
||||
"crates/aether-runtime/Cargo.toml",
|
||||
"crates/aether-task-runtime/Cargo.toml",
|
||||
"crates/aether-usage-runtime/Cargo.toml",
|
||||
"crates/aether-wallet/Cargo.toml",
|
||||
] {
|
||||
let cargo = read_workspace_file(manifest);
|
||||
for forbidden in ["redis.workspace", "redis ="] {
|
||||
if cargo.contains(forbidden) {
|
||||
dependency_violations.push(format!("{manifest} -> {forbidden}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(
|
||||
dependency_violations.is_empty(),
|
||||
"business/runtime crates must not depend on redis directly:\n{}",
|
||||
dependency_violations.join("\n")
|
||||
);
|
||||
|
||||
let mut runtime_state_violations = Vec::new();
|
||||
for path in collect_workspace_rust_files("crates/aether-runtime-state/src") {
|
||||
if path
|
||||
@@ -160,6 +194,22 @@ fn runtime_state_owns_redis_runtime_boundaries() {
|
||||
"only crates/aether-runtime-state/src/redis may depend on the redis crate directly:\n{}",
|
||||
runtime_state_violations.join("\n")
|
||||
);
|
||||
|
||||
let mut runtime_connection_violations = Vec::new();
|
||||
for path in collect_workspace_rust_files("crates/aether-runtime-state/src") {
|
||||
if path.ends_with("crates/aether-runtime-state/src/redis/client.rs") {
|
||||
continue;
|
||||
}
|
||||
let source = production_workspace_source(&path);
|
||||
if source.contains("get_multiplexed_async_connection") {
|
||||
runtime_connection_violations.push(path.display().to_string());
|
||||
}
|
||||
}
|
||||
assert!(
|
||||
runtime_connection_violations.is_empty(),
|
||||
"runtime Redis connections must be initialized only by redis/client.rs:\n{}",
|
||||
runtime_connection_violations.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user