//! 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> { 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(()) }