commit a9c835bff7686b19ae61a58e51039d0ca732ab7c
parent c14fc50442100c9592bdd8d8343c6a8088e35a7a
Author: triesap <tyson@radroots.org>
Date: Wed, 17 Jun 2026 15:31:14 -0700
runtime: rename tenant runtime surface
- rename the runtime and handle to tenant-owned types
- remove stale single-runtime loader exports
- update tests and benchmarks to the tenant runtime names
- guard the tenant runtime API with source invariants
Diffstat:
9 files changed, 169 insertions(+), 164 deletions(-)
diff --git a/crates/tangle/src/lib.rs b/crates/tangle/src/lib.rs
@@ -203,7 +203,7 @@ pub async fn run_with_config(
.map_err(|error| error.to_string())?;
tangle_runtime::logging::log_runtime_config_loaded(&config);
let runtime =
- tangle_runtime::runtime::TangleRuntime::open(config).map_err(|error| error.to_string())?;
+ tangle_runtime::runtime::TenantRuntime::open(config).map_err(|error| error.to_string())?;
tangle_runtime::server::serve_until_shutdown(runtime)
.await
.map_err(|error| error.to_string())
diff --git a/crates/tangle/tests/source_invariant.rs b/crates/tangle/tests/source_invariant.rs
@@ -43,6 +43,30 @@ fn tangle_v1_mvp_authority_requires_virtual_relay_tenancy() {
}
#[test]
+fn tenant_runtime_surface_has_no_stale_single_runtime_api_names() {
+ let workspace_root = workspace_root();
+ let runtime_source =
+ fs::read_to_string(workspace_root.join("crates/tangle_runtime/src/runtime.rs"))
+ .expect("runtime source");
+ let lib_source = fs::read_to_string(workspace_root.join("crates/tangle_runtime/src/lib.rs"))
+ .expect("lib source");
+ for forbidden in [
+ "pub struct TangleRuntime {",
+ "TangleRuntimeHandle",
+ "TangleRuntimeShared",
+ "load_base_relay_runtime_config",
+ "open_tangle_runtime_from_config_path",
+ ] {
+ assert!(
+ !runtime_source.contains(forbidden) && !lib_source.contains(forbidden),
+ "stale single-runtime API name remains: {forbidden}"
+ );
+ }
+ assert!(runtime_source.contains("pub struct TenantRuntime"));
+ assert!(runtime_source.contains("pub struct TenantRuntimeHandle"));
+}
+
+#[test]
fn scanner_removes_test_gated_items_without_removing_production_items() {
let source = [
"#[cfg(test)]\n",
diff --git a/crates/tangle_bench/src/lib.rs b/crates/tangle_bench/src/lib.rs
@@ -24,7 +24,7 @@ use tangle_runtime::{
core::{BaseRelay, BaseRelayLimitSettings, BaseRelayLimits},
outbound::RuntimeRelayMessage,
},
- runtime::{TangleRuntime, TangleRuntimeHandle},
+ runtime::{TenantRuntime, TenantRuntimeHandle},
};
use tangle_store_pocket::{
PocketEventId, PocketKind, PocketOwnedEvent, PocketOwnedFilter, PocketOwnedTags, PocketPubkey,
@@ -1400,8 +1400,8 @@ struct CountResourceControlProbe {
async fn runtime_count_resource_control_probe() -> Result<CountResourceControlProbe, String> {
let root = bench_temp_root("count-resource-controls-runtime");
let _ = fs::remove_dir_all(&root);
- let handle = TangleRuntimeHandle::new(
- TangleRuntime::open(bench_runtime_config(&root)?).map_err(|error| error.to_string())?,
+ let handle = TenantRuntimeHandle::new(
+ TenantRuntime::open(bench_runtime_config(&root)?).map_err(|error| error.to_string())?,
);
let mut auth = handle
.auth_state()
diff --git a/crates/tangle_runtime/src/lib.rs b/crates/tangle_runtime/src/lib.rs
@@ -20,11 +20,10 @@ pub mod tenant;
use std::{fmt, fs, path::Path, path::PathBuf};
use config::{
- BaseRelayRuntimeConfig, TangleHostRuntimeConfigSet, parse_base_relay_runtime_config_json,
- parse_tangle_host_runtime_config_json, parse_tenant_runtime_config_json,
+ TangleHostRuntimeConfigSet, parse_tangle_host_runtime_config_json,
+ parse_tenant_runtime_config_json,
};
use errors::BaseRelayError;
-use runtime::TangleRuntime;
pub const TANGLE_RELAY_SOFTWARE: &str = "https://github.com/radrootslabs/tangle";
pub const TANGLE_RELAY_VERSION: &str = env!("CARGO_PKG_VERSION");
@@ -79,17 +78,6 @@ impl fmt::Display for TangleRuntimeLoadError {
impl std::error::Error for TangleRuntimeLoadError {}
-pub fn load_base_relay_runtime_config(
- path: impl AsRef<Path>,
-) -> Result<BaseRelayRuntimeConfig, TangleRuntimeLoadError> {
- let path = path.as_ref();
- let raw = fs::read_to_string(path).map_err(|source| TangleRuntimeLoadError::ReadConfig {
- path: path.to_path_buf(),
- source,
- })?;
- parse_base_relay_runtime_config_json(&raw).map_err(TangleRuntimeLoadError::ParseConfig)
-}
-
pub fn load_tangle_host_runtime_config(
path: impl AsRef<Path>,
) -> Result<TangleHostRuntimeConfigSet, TangleRuntimeLoadError> {
@@ -134,13 +122,6 @@ pub fn load_tangle_host_runtime_config(
TangleHostRuntimeConfigSet::new(host, tenants).map_err(TangleRuntimeLoadError::ParseConfig)
}
-pub fn open_tangle_runtime_from_config_path(
- path: impl AsRef<Path>,
-) -> Result<TangleRuntime, TangleRuntimeLoadError> {
- let config = load_base_relay_runtime_config(path)?;
- TangleRuntime::open(config).map_err(TangleRuntimeLoadError::OpenRelay)
-}
-
fn resolve_config_path(base: Option<&Path>, path: &Path) -> PathBuf {
if path.is_absolute() {
path.to_path_buf()
diff --git a/crates/tangle_runtime/src/runtime.rs b/crates/tangle_runtime/src/runtime.rs
@@ -48,7 +48,7 @@ use tangle_store_pocket::{
};
use tokio::sync::watch;
-pub struct TangleRuntime {
+pub struct TenantRuntime {
config: BaseRelayRuntimeConfig,
relay: BaseRelay,
readiness: BaseRelayReadinessHandle,
@@ -243,7 +243,7 @@ impl TangleQueryClassifier {
}
}
-impl TangleRuntime {
+impl TenantRuntime {
pub fn open(config: BaseRelayRuntimeConfig) -> Result<Self, BaseRelayError> {
let limits = TangleRuntimeLimits::from_config(&config)?;
let relay = config.open_relay()?;
@@ -319,7 +319,7 @@ impl TangleRuntime {
}
}
-struct TangleRuntimeShared {
+struct TenantRuntimeShared {
config: Arc<BaseRelayRuntimeConfig>,
store: PocketStoreHandle,
groups: Option<GroupServiceHandle>,
@@ -331,9 +331,9 @@ struct TangleRuntimeShared {
shutdown: TangleShutdownSignal,
}
-impl TangleRuntimeShared {
- fn from_runtime(runtime: TangleRuntime) -> Self {
- let TangleRuntime {
+impl TenantRuntimeShared {
+ fn from_runtime(runtime: TenantRuntime) -> Self {
+ let TenantRuntime {
config,
relay,
readiness,
@@ -790,14 +790,14 @@ impl TangleRuntimeShared {
}
#[derive(Clone)]
-pub struct TangleRuntimeHandle {
- inner: Arc<TangleRuntimeShared>,
+pub struct TenantRuntimeHandle {
+ inner: Arc<TenantRuntimeShared>,
}
-impl TangleRuntimeHandle {
- pub fn new(runtime: TangleRuntime) -> Self {
+impl TenantRuntimeHandle {
+ pub fn new(runtime: TenantRuntime) -> Self {
Self {
- inner: Arc::new(TangleRuntimeShared::from_runtime(runtime)),
+ inner: Arc::new(TenantRuntimeShared::from_runtime(runtime)),
}
}
@@ -1382,9 +1382,9 @@ fn pocket_filter_kinds(filters: &[PocketOwnedFilter]) -> Vec<Kind> {
.collect()
}
-impl fmt::Debug for TangleRuntimeHandle {
+impl fmt::Debug for TenantRuntimeHandle {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
- formatter.write_str("TangleRuntimeHandle")
+ formatter.write_str("TenantRuntimeHandle")
}
}
@@ -2086,7 +2086,7 @@ mod tests {
use super::{
BROAD_QUERY_TIME_WINDOW_SECONDS, RuntimeClientMessage, TangleBroadQueryReason,
TangleClientRateLimitContext, TangleQueryClassification, TangleQueryClassifier,
- TangleRuntime, TangleRuntimeHandle, TangleRuntimeLimits,
+ TangleRuntimeLimits, TenantRuntime, TenantRuntimeHandle,
};
use crate::config::{BaseRelayRuntimeConfig, parse_base_relay_runtime_config_json};
use crate::event_bus::{TangleEventBus, TangleEventReceiveError, TangleEventReceiver};
@@ -2124,7 +2124,7 @@ mod tests {
let _ = std::fs::remove_dir_all(&root);
let config = runtime_config(&root, 8);
- let mut runtime = TangleRuntime::open(config).expect("runtime");
+ let mut runtime = TenantRuntime::open(config).expect("runtime");
let mut offsets = runtime.event_bus().subscribe();
let shutdown = runtime.shutdown_signal().subscribe();
@@ -2305,8 +2305,8 @@ mod tests {
async fn runtime_publishes_stored_event_offsets_for_live_fanout() {
let root = temp_root("runtime-offset-fanout");
let _ = std::fs::remove_dir_all(&root);
- let handle = TangleRuntimeHandle::new(
- TangleRuntime::open(runtime_config(&root, 8)).expect("runtime"),
+ let handle = TenantRuntimeHandle::new(
+ TenantRuntime::open(runtime_config(&root, 8)).expect("runtime"),
);
let mut offsets = handle.subscribe_events().await;
let mut auth = handle.auth_state().await.expect("auth");
@@ -2384,7 +2384,7 @@ mod tests {
async fn runtime_rate_limits_event_pubkeys_before_storage() {
let root = temp_root("runtime-event-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let event = tangle_v2_event(FixtureKey::Member, 1_714_124_433, 1, Vec::new(), "limited")
.expect("event");
let rule = runtime.config().rate_limits().event().per_pubkey();
@@ -2397,7 +2397,7 @@ mod tests {
.rate_limiter()
.record(key.clone(), rule, UnixTimestamp::new(1_714_124_433));
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
assert_eq!(
@@ -2424,7 +2424,7 @@ mod tests {
async fn runtime_rate_limits_event_kinds_before_storage() {
let root = temp_root("runtime-event-kind-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let event = tangle_v2_event(FixtureKey::Admin, 1_714_124_433, 1, Vec::new(), "limited")
.expect("event");
let rule = runtime.config().rate_limits().event().per_kind();
@@ -2434,7 +2434,7 @@ mod tests {
.rate_limiter()
.record(key.clone(), rule, UnixTimestamp::new(1_714_124_433));
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
assert_eq!(
@@ -2460,7 +2460,7 @@ mod tests {
async fn runtime_rate_limits_event_peer_ips_partition_peers_and_precede_identity_keys() {
let root = temp_root("runtime-event-ip-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let rule = runtime.config().rate_limits().event().per_ip();
let saturated_peer_ip = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 20));
let other_peer_ip = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 21));
@@ -2479,7 +2479,7 @@ mod tests {
let allowed_event =
tangle_v2_event(FixtureKey::Owner, 1_714_124_435, 2, Vec::new(), "allowed")
.expect("allowed event");
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
assert_eq!(
@@ -2541,7 +2541,7 @@ mod tests {
async fn runtime_rate_limits_auth_pubkeys_before_authentication() {
let root = temp_root("runtime-auth-pubkey-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let auth_event =
tangle_v2_auth_event(FixtureKey::Member, "challenge-a", 120).expect("auth event");
let rule = runtime.config().rate_limits().auth().per_pubkey();
@@ -2554,7 +2554,7 @@ mod tests {
.rate_limiter()
.record(key.clone(), rule, UnixTimestamp::new(120));
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
auth.issue_challenge("challenge-a", UnixTimestamp::new(100))
.expect("challenge");
@@ -2583,7 +2583,7 @@ mod tests {
async fn runtime_rate_limits_auth_peer_ips_before_authentication() {
let root = temp_root("runtime-auth-ip-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let auth_event =
tangle_v2_auth_event(FixtureKey::Member, "challenge-a", 120).expect("auth event");
let rule = runtime.config().rate_limits().auth().per_ip();
@@ -2594,7 +2594,7 @@ mod tests {
.rate_limiter()
.record(key.clone(), rule, UnixTimestamp::new(120));
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
auth.issue_challenge("challenge-a", UnixTimestamp::new(100))
.expect("challenge");
@@ -2626,7 +2626,7 @@ mod tests {
async fn runtime_rate_limits_auth_failures() {
let root = temp_root("runtime-auth-failure-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let auth_event = tangle_v2_event(FixtureKey::Member, 1_714_124_433, 22_242, Vec::new(), "")
.expect("auth event");
let key =
@@ -2637,7 +2637,7 @@ mod tests {
.rate_limiter()
.record(key.clone(), rule, UnixTimestamp::new(1_714_124_433));
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
assert_eq!(
@@ -2664,7 +2664,7 @@ mod tests {
async fn runtime_rate_limits_auth_failures_by_peer_ip() {
let root = temp_root("runtime-auth-failure-ip-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let auth_event = tangle_v2_event(FixtureKey::Admin, 1_714_124_433, 22_242, Vec::new(), "")
.expect("auth event");
let peer_ip = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 31));
@@ -2675,7 +2675,7 @@ mod tests {
.rate_limiter()
.record(key.clone(), rule, UnixTimestamp::new(1_714_124_433));
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
assert_eq!(
@@ -2705,7 +2705,7 @@ mod tests {
async fn runtime_preserves_chorus_auth_failure_rate_limit_parity() {
let root = temp_root("runtime-chorus-auth-rate-limit-parity");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let pubkey_event =
tangle_v2_event(FixtureKey::Member, 1_714_124_433, 22_242, Vec::new(), "")
.expect("pubkey auth event");
@@ -2731,7 +2731,7 @@ mod tests {
UnixTimestamp::new(1_714_124_434),
);
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
assert_eq!(
@@ -2782,7 +2782,7 @@ mod tests {
async fn runtime_rate_limits_group_writes_by_pubkey() {
let root = temp_root("runtime-group-pubkey-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let event = tangle_v2_event(
FixtureKey::Member,
1_714_124_433,
@@ -2801,7 +2801,7 @@ mod tests {
.rate_limiter()
.record(key.clone(), rule, UnixTimestamp::new(1_714_124_433));
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
assert_eq!(
@@ -2828,7 +2828,7 @@ mod tests {
async fn runtime_rate_limits_group_writes_by_peer_ip() {
let root = temp_root("runtime-group-ip-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let event = tangle_v2_event(
FixtureKey::Member,
1_714_124_433,
@@ -2845,7 +2845,7 @@ mod tests {
.rate_limiter()
.record(key.clone(), rule, UnixTimestamp::new(1_714_124_433));
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
assert_eq!(
@@ -2875,7 +2875,7 @@ mod tests {
async fn runtime_rate_limits_group_writes_by_group_id() {
let root = temp_root("runtime-group-write-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let group_id = GroupId::new("Farm").expect("group");
let event = tangle_v2_event(
FixtureKey::Member,
@@ -2892,7 +2892,7 @@ mod tests {
.rate_limiter()
.record(key.clone(), rule, UnixTimestamp::new(1_714_124_433));
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
assert_eq!(
@@ -2919,7 +2919,7 @@ mod tests {
async fn runtime_rate_limits_group_writes_by_kind() {
let root = temp_root("runtime-group-kind-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let event = tangle_v2_event(
FixtureKey::Member,
1_714_124_433,
@@ -2936,7 +2936,7 @@ mod tests {
.rate_limiter()
.record(key.clone(), rule, UnixTimestamp::new(1_714_124_433));
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
assert_eq!(
@@ -2962,7 +2962,7 @@ mod tests {
async fn runtime_rate_limits_group_join_flows() {
let root = temp_root("runtime-group-join-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let group_id = GroupId::new("Farm").expect("group");
let event = tangle_v2_event(
FixtureKey::Member,
@@ -2979,7 +2979,7 @@ mod tests {
.rate_limiter()
.record(key.clone(), rule, UnixTimestamp::new(1_714_124_433));
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
assert_eq!(
@@ -3005,7 +3005,7 @@ mod tests {
async fn runtime_rate_limits_group_join_flows_by_peer_ip() {
let root = temp_root("runtime-group-join-ip-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let group_id = GroupId::new("Farm").expect("group");
let event = tangle_v2_event(
FixtureKey::Member,
@@ -3023,7 +3023,7 @@ mod tests {
.rate_limiter()
.record(key.clone(), rule, UnixTimestamp::new(1_714_124_433));
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
assert_eq!(
@@ -3054,9 +3054,9 @@ mod tests {
async fn runtime_rate_limits_req_authenticated_pubkeys() {
let root = temp_root("runtime-req-pubkey-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let rule = runtime.config().rate_limits().req().per_pubkey();
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
auth.issue_challenge("challenge-a", UnixTimestamp::new(100))
.expect("challenge");
@@ -3112,7 +3112,7 @@ mod tests {
async fn runtime_rate_limits_req_connections() {
let root = temp_root("runtime-req-connection-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let rule = runtime.config().rate_limits().req().per_connection();
let key = TangleRateLimitKey::connection(TangleRateLimitScope::Req, 77);
for _ in 0..rule.max_hits() {
@@ -3120,7 +3120,7 @@ mod tests {
.rate_limiter()
.record(key.clone(), rule, UnixTimestamp::new(1_714_124_433));
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
let subscription_id = SubscriptionId::new("limited-req-connection").expect("subscription");
let filters = vec![filter_from_value(&json!({"kinds": [1], "limit": 1})).expect("filter")];
@@ -3152,7 +3152,7 @@ mod tests {
async fn runtime_rate_limits_req_filter_groups() {
let root = temp_root("runtime-req-group-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let group_id = GroupId::new("Farm").expect("group");
let rule = runtime.config().rate_limits().req().per_group();
let key = TangleRateLimitKey::group(TangleRateLimitScope::Req, group_id);
@@ -3161,7 +3161,7 @@ mod tests {
.rate_limiter()
.record(key.clone(), rule, UnixTimestamp::new(1_714_124_433));
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
let subscription_id = SubscriptionId::new("limited-req-group").expect("subscription");
let filters =
@@ -3252,8 +3252,8 @@ mod tests {
async fn runtime_count_hll_accepts_public_pocket_selector() {
let root = temp_root("runtime-count-hll");
let _ = std::fs::remove_dir_all(&root);
- let handle = TangleRuntimeHandle::new(
- TangleRuntime::open(runtime_config(&root, 8)).expect("runtime"),
+ let handle = TenantRuntimeHandle::new(
+ TenantRuntime::open(runtime_config(&root, 8)).expect("runtime"),
);
let mut auth = handle.auth_state().await.expect("auth");
let target = "c".repeat(64);
@@ -3329,7 +3329,7 @@ mod tests {
async fn runtime_rate_limits_count_peer_ips() {
let root = temp_root("runtime-count-ip-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let rule = runtime.config().rate_limits().count().per_ip();
let peer_ip = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 9));
let key = TangleRateLimitKey::ip(TangleRateLimitScope::Count, peer_ip);
@@ -3338,7 +3338,7 @@ mod tests {
.rate_limiter()
.record(key.clone(), rule, UnixTimestamp::new(1_714_124_433));
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
let subscription_id = SubscriptionId::new("limited-count-ip").expect("subscription");
let filters = vec![
@@ -3371,8 +3371,8 @@ mod tests {
async fn runtime_rejects_search_req_and_count_as_unsupported() {
let root = temp_root("runtime-search-unsupported");
let _ = std::fs::remove_dir_all(&root);
- let handle = TangleRuntimeHandle::new(
- TangleRuntime::open(runtime_config(&root, 8)).expect("runtime"),
+ let handle = TenantRuntimeHandle::new(
+ TenantRuntime::open(runtime_config(&root, 8)).expect("runtime"),
);
let mut auth = handle.auth_state().await.expect("auth");
let req_id = SubscriptionId::new("search-req").expect("req");
@@ -3422,7 +3422,7 @@ mod tests {
async fn runtime_rate_limits_count_filter_kinds() {
let root = temp_root("runtime-count-kind-rate-limit");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let kind = Kind::new(1).expect("kind");
let rule = runtime.config().rate_limits().count().per_kind();
let key = TangleRateLimitKey::kind(TangleRateLimitScope::Count, kind);
@@ -3431,7 +3431,7 @@ mod tests {
.rate_limiter()
.record(key.clone(), rule, UnixTimestamp::new(1_714_124_433));
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
let subscription_id = SubscriptionId::new("limited-count-kind").expect("subscription");
let filters = vec![
@@ -3463,7 +3463,7 @@ mod tests {
async fn runtime_refuses_broad_count_queries_before_rate_limits() {
let root = temp_root("runtime-count-broad-refusal");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root, 8)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, 8)).expect("runtime");
let rule = runtime.config().rate_limits().count().broad();
let key = TangleRateLimitKey::query_class(
TangleRateLimitScope::Count,
@@ -3474,7 +3474,7 @@ mod tests {
.rate_limiter()
.record(key.clone(), rule, UnixTimestamp::new(1_714_124_433));
}
- let handle = TangleRuntimeHandle::new(runtime);
+ let handle = TenantRuntimeHandle::new(runtime);
let mut auth = handle.auth_state().await.expect("auth");
let subscription_id = SubscriptionId::new("limited-count-broad").expect("subscription");
let filters = vec![filter_from_value(&json!({"limit": 1})).expect("filter")];
@@ -3506,8 +3506,8 @@ mod tests {
async fn runtime_refuses_expensive_count_queries_deterministically() {
let root = temp_root("runtime-count-expensive-refusal");
let _ = std::fs::remove_dir_all(&root);
- let handle = TangleRuntimeHandle::new(
- TangleRuntime::open(runtime_config(&root, 8)).expect("runtime"),
+ let handle = TenantRuntimeHandle::new(
+ TenantRuntime::open(runtime_config(&root, 8)).expect("runtime"),
);
let mut auth = handle.auth_state().await.expect("auth");
let cases = [
@@ -3559,8 +3559,8 @@ mod tests {
async fn runtime_publishes_generated_group_event_offsets_for_live_fanout() {
let root = temp_root("runtime-generated-offset-fanout");
let _ = std::fs::remove_dir_all(&root);
- let handle = TangleRuntimeHandle::new(
- TangleRuntime::open(runtime_config(&root, 8)).expect("runtime"),
+ let handle = TenantRuntimeHandle::new(
+ TenantRuntime::open(runtime_config(&root, 8)).expect("runtime"),
);
let mut offsets = handle.subscribe_events().await;
let mut auth = handle.auth_state().await.expect("auth");
@@ -3680,8 +3680,8 @@ mod tests {
async fn runtime_group_concurrency_duplicate_create_accepts_one_projection() {
let root = temp_root("runtime-group-concurrency-duplicate-create");
let _ = std::fs::remove_dir_all(&root);
- let handle = TangleRuntimeHandle::new(
- TangleRuntime::open(runtime_config(&root, 32)).expect("runtime"),
+ let handle = TenantRuntimeHandle::new(
+ TenantRuntime::open(runtime_config(&root, 32)).expect("runtime"),
);
let mut offsets = handle.subscribe_events().await;
let owner_auth =
@@ -3753,8 +3753,8 @@ mod tests {
async fn runtime_group_concurrency_duplicate_join_accepts_one_membership() {
let root = temp_root("runtime-group-concurrency-duplicate-join");
let _ = std::fs::remove_dir_all(&root);
- let handle = TangleRuntimeHandle::new(
- TangleRuntime::open(runtime_config_with_public_join(&root, 32)).expect("runtime"),
+ let handle = TenantRuntimeHandle::new(
+ TenantRuntime::open(runtime_config_with_public_join(&root, 32)).expect("runtime"),
);
let mut offsets = handle.subscribe_events().await;
let mut owner_auth =
@@ -3821,8 +3821,8 @@ mod tests {
async fn runtime_group_concurrency_join_and_leave_match_rebuild() {
let root = temp_root("runtime-group-concurrency-join-leave");
let _ = std::fs::remove_dir_all(&root);
- let handle = TangleRuntimeHandle::new(
- TangleRuntime::open(runtime_config_with_public_join(&root, 32)).expect("runtime"),
+ let handle = TenantRuntimeHandle::new(
+ TenantRuntime::open(runtime_config_with_public_join(&root, 32)).expect("runtime"),
);
let mut owner_auth = authenticated_runtime_state(
&handle,
@@ -3914,8 +3914,8 @@ mod tests {
async fn runtime_group_concurrency_delete_tombstone_blocks_normal_write() {
let root = temp_root("runtime-group-concurrency-delete-write");
let _ = std::fs::remove_dir_all(&root);
- let handle = TangleRuntimeHandle::new(
- TangleRuntime::open(runtime_config(&root, 32)).expect("runtime"),
+ let handle = TenantRuntimeHandle::new(
+ TenantRuntime::open(runtime_config(&root, 32)).expect("runtime"),
);
let mut owner_auth =
authenticated_runtime_state(&handle, FixtureKey::Owner, "owner-delete", 1_714_126_400)
@@ -3999,8 +3999,8 @@ mod tests {
async fn runtime_group_concurrency_membership_mutation_matches_rebuild() {
let root = temp_root("runtime-group-concurrency-membership-mutation");
let _ = std::fs::remove_dir_all(&root);
- let handle = TangleRuntimeHandle::new(
- TangleRuntime::open(runtime_config(&root, 32)).expect("runtime"),
+ let handle = TenantRuntimeHandle::new(
+ TenantRuntime::open(runtime_config(&root, 32)).expect("runtime"),
);
let mut owner_auth = authenticated_runtime_state(
&handle,
@@ -4084,8 +4084,8 @@ mod tests {
async fn runtime_shared_services_progress_under_concurrent_event_query_count_and_fanout() {
let root = temp_root("runtime-shared-concurrency");
let _ = std::fs::remove_dir_all(&root);
- let handle = TangleRuntimeHandle::new(
- TangleRuntime::open(runtime_config(&root, 32)).expect("runtime"),
+ let handle = TenantRuntimeHandle::new(
+ TenantRuntime::open(runtime_config(&root, 32)).expect("runtime"),
);
let base_time = 1_714_126_000;
let mut owner_auth = handle.auth_state().await.expect("owner auth");
@@ -4616,7 +4616,7 @@ mod tests {
}
async fn authenticated_runtime_state(
- handle: &TangleRuntimeHandle,
+ handle: &TenantRuntimeHandle,
key: FixtureKey,
challenge: &str,
now: u64,
@@ -4646,7 +4646,7 @@ mod tests {
}
async fn runtime_event_reply(
- handle: &TangleRuntimeHandle,
+ handle: &TenantRuntimeHandle,
event: Event,
auth: &mut BaseAuthState,
now: u64,
@@ -4665,7 +4665,7 @@ mod tests {
}
fn runtime_pocket_event_reply(
- handle: &TangleRuntimeHandle,
+ handle: &TenantRuntimeHandle,
event: &PocketEvent,
auth: &mut BaseAuthState,
) -> RelayMessage {
@@ -4677,7 +4677,7 @@ mod tests {
}
async fn runtime_group_count(
- handle: &TangleRuntimeHandle,
+ handle: &TenantRuntimeHandle,
subscription_id: &str,
group_id: &str,
kind: u32,
@@ -4784,7 +4784,7 @@ mod tests {
}
fn assert_runtime_member_status(
- handle: &TangleRuntimeHandle,
+ handle: &TenantRuntimeHandle,
group_id: &str,
pubkey: &PublicKeyHex,
status: MemberStatus,
@@ -4802,7 +4802,7 @@ mod tests {
);
}
- fn assert_live_projection_matches_rebuild(handle: &TangleRuntimeHandle, group_id: &str) {
+ fn assert_live_projection_matches_rebuild(handle: &TenantRuntimeHandle, group_id: &str) {
let group_id = GroupId::new(group_id).expect("group");
let groups = handle.inner.groups.as_ref().expect("groups");
let live = groups.projection();
@@ -4829,7 +4829,7 @@ mod tests {
);
}
- fn rebuilt_projection(handle: &TangleRuntimeHandle) -> GroupProjection {
+ fn rebuilt_projection(handle: &TenantRuntimeHandle) -> GroupProjection {
let groups = handle.inner.groups.as_ref().expect("groups");
let limits = groups.limits();
let events = handle
diff --git a/crates/tangle_runtime/src/server.rs b/crates/tangle_runtime/src/server.rs
@@ -6,8 +6,8 @@ use crate::{
nip11::{BaseRelayInfoConfig, BaseRelayInfoDocument, base_relay_info_response},
ops::{BaseRelayReadinessCheckStatus, BaseRelayReadinessHandle, base_relay_ops_router},
runtime::{
- TangleRuntime, TangleRuntimeHandle, TangleRuntimeLimits, TangleRuntimeMetrics,
- TangleShutdownSignal,
+ TangleRuntimeLimits, TangleRuntimeMetrics, TangleShutdownSignal, TenantRuntime,
+ TenantRuntimeHandle,
},
session::TangleWebSocketSession,
};
@@ -48,7 +48,7 @@ impl TangleServeReport {
}
pub async fn serve_until_shutdown(
- runtime: TangleRuntime,
+ runtime: TenantRuntime,
) -> Result<TangleServeReport, BaseRelayError> {
let listener = TcpListener::bind(runtime.config().listen_addr())
.await
@@ -57,7 +57,7 @@ pub async fn serve_until_shutdown(
}
pub async fn serve_listener_until_shutdown(
- runtime: TangleRuntime,
+ runtime: TenantRuntime,
listener: TcpListener,
) -> Result<TangleServeReport, BaseRelayError> {
let listen_addr = listener
@@ -70,7 +70,7 @@ pub async fn serve_listener_until_shutdown(
let limits = runtime.limits();
let metrics = runtime.metrics().clone();
let shutdown_signal = runtime.shutdown_signal().clone();
- let runtime = TangleRuntimeHandle::new(runtime);
+ let runtime = TenantRuntimeHandle::new(runtime);
let router = tangle_http_router(
readiness,
info,
@@ -111,7 +111,7 @@ pub fn tangle_http_router(
limits: TangleRuntimeLimits,
metrics: TangleRuntimeMetrics,
shutdown: TangleShutdownSignal,
- runtime: TangleRuntimeHandle,
+ runtime: TenantRuntimeHandle,
) -> Router {
Router::new()
.route("/", get(tangle_root))
@@ -129,7 +129,7 @@ struct TangleHttpState {
info: BaseRelayInfoDocument,
limits: TangleRuntimeLimits,
shutdown: TangleShutdownSignal,
- runtime: TangleRuntimeHandle,
+ runtime: TenantRuntimeHandle,
}
async fn tangle_root(
@@ -174,7 +174,7 @@ mod tests {
config::{BaseRelayRuntimeConfig, parse_base_relay_runtime_config_json},
nip11::BaseRelayInfoConfig,
ops::BaseRelayReadinessCheckStatus,
- runtime::{TangleRuntime, TangleRuntimeHandle, TangleShutdownSignal},
+ runtime::{TangleShutdownSignal, TenantRuntime, TenantRuntimeHandle},
};
use axum::{body::to_bytes, extract::ConnectInfo};
use futures_util::{SinkExt, StreamExt};
@@ -205,7 +205,7 @@ mod tests {
async fn serve_until_shutdown_binds_listener_and_exits_on_signal() {
let root = temp_root("serve-until-shutdown");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root)).expect("runtime");
let shutdown = runtime.shutdown_signal().clone();
let task = tokio::spawn(serve_until_shutdown(runtime));
@@ -224,7 +224,7 @@ mod tests {
async fn serve_until_shutdown_accepts_websocket_upgrade() {
let root = temp_root("websocket-upgrade");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root)).expect("runtime");
let shutdown = runtime.shutdown_signal().clone();
let listener = TcpListener::bind("127.0.0.1:0").await.expect("listener");
let address = listener.local_addr().expect("address");
@@ -260,7 +260,7 @@ mod tests {
async fn serve_until_shutdown_closes_websocket_sessions() {
let root = temp_root("websocket-shutdown");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root)).expect("runtime");
let shutdown = runtime.shutdown_signal().clone();
let listener = TcpListener::bind("127.0.0.1:0").await.expect("listener");
let address = listener.local_addr().expect("address");
@@ -301,7 +301,7 @@ mod tests {
async fn websocket_session_dispatches_base_client_messages() {
let root = temp_root("websocket-dispatch");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root)).expect("runtime");
let shutdown = runtime.shutdown_signal().clone();
let listener = TcpListener::bind("127.0.0.1:0").await.expect("listener");
let address = listener.local_addr().expect("address");
@@ -421,7 +421,7 @@ mod tests {
.expect("info config")
.build_document()
.expect("info");
- let runtime = TangleRuntime::open(config).expect("runtime");
+ let runtime = TenantRuntime::open(config).expect("runtime");
let readiness = runtime.readiness_handle();
readiness.set_server_bind(BaseRelayReadinessCheckStatus::Ready);
let limits = runtime.limits();
@@ -432,7 +432,7 @@ mod tests {
limits,
metrics,
TangleShutdownSignal::new(),
- TangleRuntimeHandle::new(runtime),
+ TenantRuntimeHandle::new(runtime),
);
let nip11 = router
.clone()
diff --git a/crates/tangle_runtime/src/session.rs b/crates/tangle_runtime/src/session.rs
@@ -12,8 +12,8 @@ use crate::{
outbound::RuntimeRelayMessage,
},
runtime::{
- TangleClientMessageMetricKind, TangleClientRateLimitContext, TangleRuntimeHandle,
- TangleRuntimeLimits,
+ TangleClientMessageMetricKind, TangleClientRateLimitContext, TangleRuntimeLimits,
+ TenantRuntimeHandle,
},
};
use axum::extract::ws::{CloseFrame, Message, Utf8Bytes, WebSocket};
@@ -34,7 +34,7 @@ pub struct TangleWebSocketSession {
outbound: TangleOutboundSender,
outbound_receiver: mpsc::Receiver<Message>,
shutdown: watch::Receiver<bool>,
- runtime: TangleRuntimeHandle,
+ runtime: TenantRuntimeHandle,
limits: TangleRuntimeLimits,
auth: BaseAuthState,
subscriptions: LiveSubscriptionSet,
@@ -47,7 +47,7 @@ impl TangleWebSocketSession {
pub fn new(
limits: TangleRuntimeLimits,
shutdown: watch::Receiver<bool>,
- runtime: TangleRuntimeHandle,
+ runtime: TenantRuntimeHandle,
auth: BaseAuthState,
events: TangleEventReceiver,
) -> Result<Self, BaseRelayError> {
@@ -57,7 +57,7 @@ impl TangleWebSocketSession {
pub fn new_with_peer(
limits: TangleRuntimeLimits,
shutdown: watch::Receiver<bool>,
- runtime: TangleRuntimeHandle,
+ runtime: TenantRuntimeHandle,
auth: BaseAuthState,
events: TangleEventReceiver,
peer_ip: Option<IpAddr>,
@@ -573,7 +573,7 @@ mod tests {
event_bus::TangleEventReceiver,
rate_limits::{TangleRateLimitKey, TangleRateLimitScope},
relay::core::{BaseRelayLimitSettings, BaseRelayLimits},
- runtime::{TangleRuntime, TangleRuntimeHandle, TangleRuntimeLimits, TangleShutdownSignal},
+ runtime::{TangleRuntimeLimits, TangleShutdownSignal, TenantRuntime, TenantRuntimeHandle},
};
use axum::extract::ws::Message;
use serde_json::json;
@@ -814,7 +814,7 @@ mod tests {
let root = temp_root("connection-scope");
let _ = std::fs::remove_dir_all(&root);
let runtime =
- TangleRuntimeHandle::new(TangleRuntime::open(runtime_config(&root)).expect("runtime"));
+ TenantRuntimeHandle::new(TenantRuntime::open(runtime_config(&root)).expect("runtime"));
let metrics = runtime.metrics();
let auth_a = runtime.auth_state().await.expect("auth a");
let auth_b = runtime.auth_state().await.expect("auth b");
@@ -900,8 +900,8 @@ mod tests {
let shutdown = TangleShutdownSignal::new();
let root = temp_root("current-auth-live");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntimeHandle::new(
- TangleRuntime::open(runtime_config_with_groups(&root)).expect("runtime"),
+ let runtime = TenantRuntimeHandle::new(
+ TenantRuntime::open(runtime_config_with_groups(&root)).expect("runtime"),
);
let mut owner_auth = runtime.auth_state().await.expect("owner auth");
owner_auth
@@ -1053,7 +1053,7 @@ mod tests {
let root = temp_root("complete-req-lifecycle");
let _ = std::fs::remove_dir_all(&root);
let runtime =
- TangleRuntimeHandle::new(TangleRuntime::open(runtime_config(&root)).expect("runtime"));
+ TenantRuntimeHandle::new(TenantRuntime::open(runtime_config(&root)).expect("runtime"));
let mut auth = runtime.auth_state().await.expect("auth");
let events = runtime.subscribe_events().await;
let mut session = TangleWebSocketSession::new(
@@ -1159,8 +1159,8 @@ mod tests {
let shutdown = TangleShutdownSignal::new();
let root = temp_root("redacted-req-close");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntimeHandle::new(
- TangleRuntime::open(runtime_config_with_groups(&root)).expect("runtime"),
+ let runtime = TenantRuntimeHandle::new(
+ TenantRuntime::open(runtime_config_with_groups(&root)).expect("runtime"),
);
let mut owner_auth = runtime.auth_state().await.expect("owner auth");
owner_auth
@@ -1279,7 +1279,7 @@ mod tests {
let root = temp_root("chorus-close-scope-parity");
let _ = std::fs::remove_dir_all(&root);
let runtime =
- TangleRuntimeHandle::new(TangleRuntime::open(runtime_config(&root)).expect("runtime"));
+ TenantRuntimeHandle::new(TenantRuntime::open(runtime_config(&root)).expect("runtime"));
let metrics = runtime.metrics();
let auth_a = runtime.auth_state().await.expect("auth a");
let auth_b = runtime.auth_state().await.expect("auth b");
@@ -1395,9 +1395,9 @@ mod tests {
let shutdown = TangleShutdownSignal::new();
let root = temp_root("rate-limited-req");
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root)).expect("runtime");
let rule = runtime.config().rate_limits().req().per_connection();
- let runtime = TangleRuntimeHandle::new(runtime);
+ let runtime = TenantRuntimeHandle::new(runtime);
let auth = runtime.auth_state().await.expect("auth");
let events = runtime.subscribe_events().await;
let now = current_unix_timestamp();
@@ -1450,12 +1450,12 @@ mod tests {
let root = temp_root("event-receiver-lag");
let _ = std::fs::remove_dir_all(&root);
let runtime =
- TangleRuntime::open(runtime_config_with_outbound_queue(&root, 1)).expect("runtime");
+ TenantRuntime::open(runtime_config_with_outbound_queue(&root, 1)).expect("runtime");
let auth = runtime.auth_state().expect("auth");
let events = runtime.event_bus().subscribe();
assert_eq!(runtime.event_bus().publish(StoreOffset::new(1)), 1);
assert_eq!(runtime.event_bus().publish(StoreOffset::new(2)), 1);
- let runtime = TangleRuntimeHandle::new(runtime);
+ let runtime = TenantRuntimeHandle::new(runtime);
let metrics = runtime.metrics();
let mut session = TangleWebSocketSession::new(
session_limits(1),
@@ -1482,8 +1482,8 @@ mod tests {
let shutdown = TangleShutdownSignal::new();
let live_root = temp_root("chorus-live-fanout-parity");
let _ = std::fs::remove_dir_all(&live_root);
- let runtime = TangleRuntimeHandle::new(
- TangleRuntime::open(runtime_config_with_outbound_queue(&live_root, 1))
+ let runtime = TenantRuntimeHandle::new(
+ TenantRuntime::open(runtime_config_with_outbound_queue(&live_root, 1))
.expect("runtime"),
);
let metrics = runtime.metrics();
@@ -1555,12 +1555,12 @@ mod tests {
let lag_root = temp_root("chorus-live-lag-parity");
let _ = std::fs::remove_dir_all(&lag_root);
let runtime =
- TangleRuntime::open(runtime_config_with_outbound_queue(&lag_root, 1)).expect("runtime");
+ TenantRuntime::open(runtime_config_with_outbound_queue(&lag_root, 1)).expect("runtime");
let auth = runtime.auth_state().expect("auth");
let events = runtime.event_bus().subscribe();
assert_eq!(runtime.event_bus().publish(StoreOffset::new(1)), 1);
assert_eq!(runtime.event_bus().publish(StoreOffset::new(2)), 1);
- let runtime = TangleRuntimeHandle::new(runtime);
+ let runtime = TenantRuntimeHandle::new(runtime);
let metrics = runtime.metrics();
let mut lagged = TangleWebSocketSession::new(
session_limits(1),
@@ -1783,16 +1783,16 @@ mod tests {
fn session_runtime(
name: &str,
) -> (
- TangleRuntimeHandle,
+ TenantRuntimeHandle,
crate::relay::auth::BaseAuthState,
TangleEventReceiver,
) {
let root = temp_root(name);
let _ = std::fs::remove_dir_all(&root);
- let runtime = TangleRuntime::open(runtime_config(&root)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root)).expect("runtime");
let auth = runtime.auth_state().expect("auth");
let events = runtime.event_bus().subscribe();
- (TangleRuntimeHandle::new(runtime), auth, events)
+ (TenantRuntimeHandle::new(runtime), auth, events)
}
fn req(subscription_id: SubscriptionId) -> ClientMessage {
diff --git a/crates/tangle_runtime/tests/ops_truthfulness.rs b/crates/tangle_runtime/tests/ops_truthfulness.rs
@@ -15,7 +15,7 @@ use tangle_runtime::{
ops::BaseRelayReadinessCheckStatus,
rate_limits::{TangleRateLimitKey, TangleRateLimitScope, TangleRateLimiter},
relay::{auth::BaseAuthState, core::BaseRelay},
- runtime::TangleRuntime,
+ runtime::TenantRuntime,
};
use tangle_store_pocket::parse_pocket_event_json;
use tangle_store_pocket::{PocketEvent, PocketKind, PocketOwnedEvent, PocketOwnedTags, PocketTime};
@@ -210,7 +210,7 @@ fn operations_surfaces_match_enforced_runtime_contracts() {
.is_allowed()
);
- let runtime = TangleRuntime::open(config.clone()).expect("runtime");
+ let runtime = TenantRuntime::open(config.clone()).expect("runtime");
let pre_bind = runtime.readiness_state().response();
assert_eq!(pre_bind.status, "not_ready");
assert_eq!(pre_bind.checks.server_bind, "not_ready");
diff --git a/crates/tangle_runtime/tests/phase2_acceptance_targets.rs b/crates/tangle_runtime/tests/phase2_acceptance_targets.rs
@@ -28,7 +28,7 @@ use tangle_runtime::{
errors::BaseRelayError,
nip11::BaseRelayInfoConfig,
relay::{auth::BaseAuthState, core::BaseRelay},
- runtime::TangleRuntime,
+ runtime::TenantRuntime,
server::serve_listener_until_shutdown,
};
use tangle_store_pocket::{
@@ -349,7 +349,7 @@ async fn tangle_run_serves_until_shutdown() {
let _ = std::fs::remove_dir_all(&root);
let listener = TcpListener::bind("127.0.0.1:0").await.expect("listener");
let address = listener.local_addr().expect("address");
- let runtime = TangleRuntime::open(runtime_config(&root, address)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, address)).expect("runtime");
let shutdown = runtime.shutdown_signal().clone();
let task = tokio::spawn(serve_listener_until_shutdown(runtime, listener));
@@ -391,7 +391,7 @@ async fn websocket_clients_use_nip01_nip42_and_nip45_flows() {
let _ = std::fs::remove_dir_all(&root);
let listener = TcpListener::bind("127.0.0.1:0").await.expect("listener");
let address = listener.local_addr().expect("address");
- let runtime = TangleRuntime::open(runtime_config(&root, address)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, address)).expect("runtime");
let shutdown = runtime.shutdown_signal().clone();
let task = tokio::spawn(serve_listener_until_shutdown(runtime, listener));
let mut first = connect_nostr_socket(address).await;
@@ -560,7 +560,7 @@ async fn websocket_public_relay_covers_query_count_ephemeral_and_rejection_flows
let _ = std::fs::remove_dir_all(&root);
let listener = TcpListener::bind("127.0.0.1:0").await.expect("listener");
let address = listener.local_addr().expect("address");
- let runtime = TangleRuntime::open(runtime_config(&root, address)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, address)).expect("runtime");
let shutdown = runtime.shutdown_signal().clone();
let task = tokio::spawn(serve_listener_until_shutdown(runtime, listener));
let mut publisher = connect_nostr_socket(address).await;
@@ -754,7 +754,7 @@ async fn websocket_healthy_subscriber_receives_more_than_outbound_capacity() {
let _ = std::fs::remove_dir_all(&root);
let listener = TcpListener::bind("127.0.0.1:0").await.expect("listener");
let address = listener.local_addr().expect("address");
- let runtime = TangleRuntime::open(runtime_config(&root, address)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, address)).expect("runtime");
let shutdown = runtime.shutdown_signal().clone();
let task = tokio::spawn(serve_listener_until_shutdown(runtime, listener));
let mut publisher = connect_nostr_socket(address).await;
@@ -817,7 +817,7 @@ async fn websocket_nip29_group_lifecycle_state_and_live_paths_are_integrated() {
let _ = std::fs::remove_dir_all(&root);
let listener = TcpListener::bind("127.0.0.1:0").await.expect("listener");
let address = listener.local_addr().expect("address");
- let runtime = TangleRuntime::open(runtime_config(&root, address)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, address)).expect("runtime");
let shutdown = runtime.shutdown_signal().clone();
let task = tokio::spawn(serve_listener_until_shutdown(runtime, listener));
let mut owner = connect_nostr_socket(address).await;
@@ -1005,7 +1005,7 @@ async fn websocket_private_and_hidden_groups_do_not_leak_through_query_count_or_
let _ = std::fs::remove_dir_all(&root);
let listener = TcpListener::bind("127.0.0.1:0").await.expect("listener");
let address = listener.local_addr().expect("address");
- let runtime = TangleRuntime::open(runtime_config(&root, address)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, address)).expect("runtime");
let shutdown = runtime.shutdown_signal().clone();
let task = tokio::spawn(serve_listener_until_shutdown(runtime, listener));
let mut owner_writer = connect_nostr_socket(address).await;
@@ -1485,7 +1485,7 @@ async fn nip11_includes_cors_headers_and_truthful_supported_nips() {
let _ = std::fs::remove_dir_all(&root);
let listener = TcpListener::bind("127.0.0.1:0").await.expect("listener");
let address = listener.local_addr().expect("address");
- let runtime = TangleRuntime::open(runtime_config(&root, address)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, address)).expect("runtime");
let shutdown = runtime.shutdown_signal().clone();
let task = tokio::spawn(serve_listener_until_shutdown(runtime, listener));
@@ -1979,14 +1979,14 @@ fn runtime_live_fanout_offset_lookup_does_not_lock_relay_state() {
fn runtime_shared_shell_does_not_keep_transitional_base_relay_mutex() {
let runtime = include_str!("../src/runtime.rs");
let shared_shell = runtime
- .split("struct TangleRuntimeShared {")
+ .split("struct TenantRuntimeShared {")
.nth(1)
.expect("shared shell")
- .split("impl TangleRuntimeShared")
+ .split("impl TenantRuntimeShared")
.next()
.expect("shared shell fields");
let handle_impl = runtime
- .split("impl TangleRuntimeHandle")
+ .split("impl TenantRuntimeHandle")
.nth(1)
.expect("runtime handle")
.split("fn auth_response_failed")
@@ -2054,7 +2054,7 @@ fn projection_and_outbox_recover_from_canonical_pocket_events() {
.expect("note");
{
- let mut runtime = TangleRuntime::open(config.clone()).expect("runtime");
+ let mut runtime = TenantRuntime::open(config.clone()).expect("runtime");
assert_relay_ok(
runtime
.relay_mut()
@@ -2100,7 +2100,7 @@ fn projection_and_outbox_recover_from_canonical_pocket_events() {
delete_group_extra_records(config.pocket_config());
- let recovered = TangleRuntime::open(config.clone()).expect("recovered");
+ let recovered = TenantRuntime::open(config.clone()).expect("recovered");
let readiness = recovered.readiness_state().response();
assert_eq!(readiness.checks.group_projection, "ready");
assert_eq!(readiness.checks.group_outbox_replay, "ready");
@@ -2173,7 +2173,7 @@ async fn relay_generated_events_are_stored_projected_and_broadcast_to_websocket_
let _ = std::fs::remove_dir_all(&root);
let listener = TcpListener::bind("127.0.0.1:0").await.expect("listener");
let address = listener.local_addr().expect("address");
- let runtime = TangleRuntime::open(runtime_config(&root, address)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, address)).expect("runtime");
let shutdown = runtime.shutdown_signal().clone();
let task = tokio::spawn(serve_listener_until_shutdown(runtime, listener));
let mut owner = connect_nostr_socket(address).await;
@@ -2283,7 +2283,7 @@ async fn private_relay_generated_events_reach_authorized_websocket_subscribers()
let _ = std::fs::remove_dir_all(&root);
let listener = TcpListener::bind("127.0.0.1:0").await.expect("listener");
let address = listener.local_addr().expect("address");
- let runtime = TangleRuntime::open(runtime_config(&root, address)).expect("runtime");
+ let runtime = TenantRuntime::open(runtime_config(&root, address)).expect("runtime");
let shutdown = runtime.shutdown_signal().clone();
let task = tokio::spawn(serve_listener_until_shutdown(runtime, listener));
let mut owner_writer = connect_nostr_socket(address).await;