Skip to content

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

refactor(flows): extract test-only serve counter into helper

Steven Enamakel899d99e6ab16
diff --git a/crates/openhuman-core/src/flows/catalog_storage.rs b/crates/openhuman-core/src/flows/catalog_storage.rs
index f8bcebe675..6cef552751 100644
--- a/crates/openhuman-core/src/flows/catalog_storage.rs
+++ b/crates/openhuman-core/src/flows/catalog_storage.rs
@@ -132,6 +132,8 @@ pub(crate) async fn register(
)
.await?;
#[cfg(test)]
+ record_served(&path);
+ #[cfg(test)]
pause_before_cache_insert(&path).await;
let registration = Arc::new(CatalogStorageRegistration {
address: CallbackAddress {
@@ -154,17 +156,21 @@ async fn pause_before_cache_insert(path: &str) {
.unwrap_or_else(std::sync::PoisonError::into_inner)
.remove(path);
if let Some(gate) = gate {
- REGISTRATION_SERVE_COUNTS
- .lock()
- .unwrap_or_else(std::sync::PoisonError::into_inner)
- .entry(path.to_owned())
- .and_modify(|count| *count += 1)
- .or_insert(1);
let _ = gate.entered.send(());
let _ = gate.release.await;
}
}
+#[cfg(test)]
+fn record_served(path: &str) {
+ REGISTRATION_SERVE_COUNTS
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner)
+ .entry(path.to_owned())
+ .and_modify(|count| *count += 1)
+ .or_insert(1);
+}
+
fn path_for(key: &RegistrationKey) -> String {
let workspace = key.workspace_dir.as_os_str().as_encoded_bytes();
let scope = key.scope.as_bytes();