Skip to content

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

feat(cron): add host scheduler dispatch

Steven Enamakel1091898a81a9
diff --git a/crates/openhuman-core/src/cron/scheduler/host.rs b/crates/openhuman-core/src/cron/scheduler/host.rs
index 4631022601..2cdb97c78a 100644
--- a/crates/openhuman-core/src/cron/scheduler/host.rs
+++ b/crates/openhuman-core/src/cron/scheduler/host.rs
@@ -225,6 +225,12 @@ impl JobDispatcher {
}
}
+ /// The dispatch context the scheduler's ports act under.
+ #[cfg(test)]
+ pub(crate) fn dispatch_ctx(&self) -> crate::core::runtime::DispatchCtx {
+ self.binding.dispatch_ctx()
+ }
+
/// Read the due jobs and dispatch them; the count dispatched. Errors when
/// the store cannot be read.
pub(crate) async fn tick(&mut self, config: &Config) -> Result<usize> {
diff --git a/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs b/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs
index 3566a4aab9..26abaac0e1 100644
--- a/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs
@@ -466,7 +466,8 @@ async fn a_flow_schedule_job_is_skipped_when_the_flows_component_is_off() {
#[tokio::test]
async fn a_dispatcher_binds_the_context_it_is_handed_not_the_ambient_one() {
- let (_tmp, config) = test_config().await;
+ let tmp = TempDir::new().unwrap();
+ let config = test_config(&tmp).await;
let security = security(&config);
let handed = CoreContext::for_test(crate::core::runtime::DomainSet::full(), None);
let ambient = CoreContext::for_test(crate::core::runtime::DomainSet::full(), None);
@@ -481,14 +482,7 @@ async fn a_dispatcher_binds_the_context_it_is_handed_not_the_ambient_one() {
)
})
.await;
- let bound = dispatcher.binding.dispatch_ctx();
+ let bound = dispatcher.dispatch_ctx();
assert!(Arc::ptr_eq(bound.core().expect("bound"), &handed));
assert!(!Arc::ptr_eq(bound.core().unwrap(), &ambient));
-
- // An unbound context binds nothing, whatever the task's scope is.
- let unbound = CoreContext::scope(ambient, async {
- JobDispatcher::new(&crate::core::runtime::DispatchCtx::unbound(), &config, &security)
- })
- .await;
- assert!(unbound.binding.context.is_none());
}