Skip to content

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

refactor(tinyflows): hoist served object registration to module scope

Steven Enamakele495968554c6
diff --git a/crates/openhuman-core/src/modules/tinyflows.rs b/crates/openhuman-core/src/modules/tinyflows.rs
index c3cfac0dcf..8c063e6041 100644
--- a/crates/openhuman-core/src/modules/tinyflows.rs
+++ b/crates/openhuman-core/src/modules/tinyflows.rs
@@ -32,6 +32,15 @@ pub(crate) const MODULE_ID: &str = "tinyflows";
/// name serves them all, and the object path names the scope.
pub(crate) const HOST_BUS_NAME: &str = "ai.tinyhumans.openhuman.CronHost";
+/// Owns the interfaces served at one module-bus object path.
+pub(crate) struct ServedObjectRegistration(String);
+
+impl Drop for ServedObjectRegistration {
+ fn drop(&mut self) {
+ unserve(std::mem::take(&mut self.0));
+ }
+}
+
/// The switched-off message callers surface verbatim.
pub(crate) fn disabled_message() -> String {
format!(
@@ -220,23 +229,12 @@ mod imp {
let _ = connection.unserve(&object_path).await;
return Err(error.to_string());
}
- Ok(ServedObjectRegistration { path })
+ Ok(ServedObjectRegistration(path))
})
.await
.map_err(|error| format!("serving the host object did not finish: {error}"))?
}
- /// Owns the registration of interfaces served at one path.
- pub(crate) struct ServedObjectRegistration {
- path: String,
- }
-
- impl Drop for ServedObjectRegistration {
- fn drop(&mut self) {
- unserve(std::mem::take(&mut self.path));
- }
- }
-
/// Stop serving `path`. Fire and forget: a call already admitted finishes.
/// Without a runtime to run on (a sync drop at exit) the object is left;
/// the process is ending anyway.