Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(modules): use LazyLock for storage callback map

Steven Enamakel7253dc2e92f7
diff --git a/crates/openhuman-core/src/modules/ops.rs b/crates/openhuman-core/src/modules/ops.rs
index 8ca7bd2224..7c6edcaa5e 100644
--- a/crates/openhuman-core/src/modules/ops.rs
+++ b/crates/openhuman-core/src/modules/ops.rs
@@ -215,15 +215,17 @@ fn needs_storage_callback(id: &str) -> bool {
}
/// Serializes creation and retention of module-scoped storage callback bindings.
-static STORAGE_CALLBACK_LOADS: tokio::sync::Mutex<
- std::collections::HashMap<
- String,
- (
- std::sync::Arc<tinybus::module::HostCallbackBinding>,
- tinystoragedrivers_busproxy::ServedStorage,
- ),
+static STORAGE_CALLBACK_LOADS: std::sync::LazyLock<
+ tokio::sync::Mutex<
+ std::collections::HashMap<
+ String,
+ (
+ std::sync::Arc<tinybus::module::HostCallbackBinding>,
+ tinystoragedrivers_busproxy::ServedStorage,
+ ),
+ >,
>,
-> = tokio::sync::Mutex::const_new(std::collections::HashMap::new());
+> = std::sync::LazyLock::new(|| tokio::sync::Mutex::new(std::collections::HashMap::new()));
async fn ensure_loaded_with_storage_callback(
resolver: &Resolver,
diff --git a/crates/openhuman-core/src/modules/storage_host.rs b/crates/openhuman-core/src/modules/storage_host.rs
index f23d13880e..b78bb1ec0c 100644
--- a/crates/openhuman-core/src/modules/storage_host.rs
+++ b/crates/openhuman-core/src/modules/storage_host.rs
@@ -700,7 +700,7 @@ pub(super) async fn prepare_module_callbacks(
}
/// Prepare a callback storage endpoint for a module host on `connection`.
-pub(super) async fn prepare_callbacks(
+pub(crate) async fn prepare_callbacks(
connection: &tinybus::Connection,
modules: &tinybus::module::ModuleHost,
) -> tinybus::Result<(