initial commit

This commit is contained in:
Timur Gordon
2025-08-26 14:49:21 +02:00
commit 767c66fb6a
66 changed files with 22035 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
//! Simple test for the queue_and_wait functionality
use hero_supervisor::{
supervisor::{Supervisor, ProcessManagerType},
runner::RunnerConfig,
job::{JobBuilder, JobType},
};
use std::time::Duration;
use std::path::PathBuf;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("🧪 Testing queue_and_wait functionality directly");
// Create supervisor
let mut supervisor = Supervisor::new();
// Create a runner config
let config = RunnerConfig::new(
"test_actor".to_string(),
hero_supervisor::runner::RunnerType::OSISRunner,
PathBuf::from("./target/debug/examples/mock_runner"),
"/tmp/test_db".to_string(),
"redis://localhost:6379".to_string(),
);
// Add runner
println!(" Adding test runner...");
supervisor.add_runner(config, ProcessManagerType::Simple).await?;
// Start runner
println!("▶️ Starting test runner...");
supervisor.start_runner("test_actor").await?;
// Create a test job
let job = JobBuilder::new()
.caller_id("test_client")
.context_id("direct_test")
.payload("print('Direct queue_and_wait test!');")
.job_type(JobType::OSIS)
.runner_name("test_actor")
.timeout(Duration::from_secs(10))
.build()?;
println!("🚀 Testing queue_and_wait directly...");
println!("📋 Job ID: {}", job.id);
// Test queue_and_wait directly
match supervisor.queue_and_wait("test_actor", job, 10).await {
Ok(Some(result)) => {
println!("✅ queue_and_wait succeeded!");
println!("📤 Result: {}", result);
}
Ok(None) => {
println!("⏰ queue_and_wait timed out");
}
Err(e) => {
println!("❌ queue_and_wait failed: {}", e);
}
}
// Cleanup
println!("🧹 Cleaning up...");
supervisor.stop_runner("test_actor", false).await?;
supervisor.remove_runner("test_actor").await?;
println!("✅ Direct test completed!");
Ok(())
}