rename worker to actor
This commit is contained in:
@@ -4,8 +4,8 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[[bin]]
|
||||
name = "supervisor_worker_demo"
|
||||
path = "supervisor_worker_demo.rs"
|
||||
name = "supervisor_actor_demo"
|
||||
path = "supervisor_actor_demo.rs"
|
||||
|
||||
[dependencies]
|
||||
hero_supervisor = { path = "../supervisor" }
|
||||
|
@@ -1,8 +1,8 @@
|
||||
//! Hero Supervisor Worker Demo
|
||||
//! Hero Supervisor Actor Demo
|
||||
//!
|
||||
//! This example demonstrates the new Hero Supervisor API with:
|
||||
//! - Synchronous build() method
|
||||
//! - Asynchronous start_workers() method
|
||||
//! - Asynchronous start_actors() method
|
||||
//! - Proper cleanup on program exit
|
||||
//! - Signal handling for graceful shutdown
|
||||
|
||||
@@ -18,21 +18,21 @@ async fn run_supervisor_demo() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Build supervisor synchronously (no .await needed)
|
||||
let supervisor = SupervisorBuilder::new()
|
||||
.redis_url("redis://127.0.0.1:6379")
|
||||
.osis_worker("/usr/local/bin/osis_worker")
|
||||
.sal_worker("/usr/local/bin/sal_worker")
|
||||
.v_worker("/usr/local/bin/v_worker")
|
||||
.python_worker("/usr/local/bin/python_worker")
|
||||
.worker_env_var("REDIS_URL", "redis://127.0.0.1:6379")
|
||||
.worker_env_var("LOG_LEVEL", "info")
|
||||
.osis_actor("/usr/local/bin/osis_actor")
|
||||
.sal_actor("/usr/local/bin/sal_actor")
|
||||
.v_actor("/usr/local/bin/v_actor")
|
||||
.python_actor("/usr/local/bin/python_actor")
|
||||
.actor_env_var("REDIS_URL", "redis://127.0.0.1:6379")
|
||||
.actor_env_var("LOG_LEVEL", "info")
|
||||
.build()?;
|
||||
|
||||
println!("{}", "✅ Supervisor built successfully!".green());
|
||||
println!("{}", "Starting workers asynchronously...".yellow());
|
||||
println!("{}", "Starting actors asynchronously...".yellow());
|
||||
|
||||
// Start workers asynchronously
|
||||
supervisor.start_workers().await?;
|
||||
// Start actors asynchronously
|
||||
supervisor.start_actors().await?;
|
||||
|
||||
println!("{}", "✅ All workers started successfully!".green());
|
||||
println!("{}", "✅ All actors started successfully!".green());
|
||||
|
||||
// Demonstrate job creation and execution
|
||||
println!("{}", "\n📋 Creating and running test jobs...".cyan().bold());
|
||||
@@ -43,7 +43,7 @@ async fn run_supervisor_demo() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Submit and run the job
|
||||
match supervisor.new_job()
|
||||
.script_type(ScriptType::OSIS)
|
||||
.script("println('Hello from OSIS worker!')")
|
||||
.script("println('Hello from OSIS actor!')")
|
||||
.timeout(Duration::from_secs(30))
|
||||
.await_response().await {
|
||||
Ok(result) => {
|
||||
@@ -60,7 +60,7 @@ async fn run_supervisor_demo() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
println!("{}", "\n🛑 Shutdown signal received, cleaning up...".yellow().bold());
|
||||
|
||||
// Cleanup workers before exit
|
||||
// Cleanup actors before exit
|
||||
supervisor.cleanup_and_shutdown().await?;
|
||||
|
||||
println!("{}", "✅ Cleanup completed. Goodbye!".green().bold());
|
||||
|
Reference in New Issue
Block a user