From 32282f465e1add990c16af938d0fc5e9712e42f0 Mon Sep 17 00:00:00 2001 From: Maxime Van Hees Date: Thu, 14 Aug 2025 14:15:19 +0200 Subject: [PATCH] updated actor to following naming conventions --- Cargo.lock | 24 +++++++++--------- Cargo.toml | 7 ++++-- README.md | 40 +++++++++++++++++++++++++++++- examples/actor.rs | 6 ++--- examples/scripts/test_logging.rhai | 13 ++++++++++ src/lib.rs | 4 +-- 6 files changed, 74 insertions(+), 20 deletions(-) create mode 100644 examples/scripts/test_logging.rhai diff --git a/Cargo.lock b/Cargo.lock index 6770bee..c8a06c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -191,11 +191,12 @@ dependencies = [ [[package]] name = "baobab_actor" version = "0.1.0" -source = "git+https://git.ourworld.tf/herocode/baobab.git#6c5c97e64782f7d05ff22bbafba2498f4b906463" dependencies = [ + "anyhow", "async-trait", "chrono", "clap", + "crossterm", "env_logger", "hero_job", "hero_supervisor", @@ -203,6 +204,7 @@ dependencies = [ "heromodels-derive", "heromodels_core", "log", + "ratatui", "redis", "rhai", "serde", @@ -337,9 +339,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.42" +version = "4.5.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed87a9d530bb41a67537289bafcac159cb3ee28460e0a4571123d2a778a6a882" +checksum = "50fd97c9dc2399518aa331917ac6f274280ec5eb34e555dd291899745c48ec6f" dependencies = [ "clap_builder", "clap_derive", @@ -347,9 +349,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.42" +version = "4.5.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64f4f3f3c77c94aff3c7e9aac9a2ca1974a5adf392a8bb751e827d6d127ab966" +checksum = "c35b5830294e1fa0462034af85cc95225a4cb07092c088c55bda3147cfcd8f65" dependencies = [ "anstream", "anstyle", @@ -935,9 +937,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17da50a276f1e01e0ba6c029e47b7100754904ee8a278f886546e98575380785" +checksum = "f3c0b69cfcb4e1b9f1bf2f53f95f766e4661169728ec61cd3fe5a0166f2d1386" dependencies = [ "atomic-waker", "bytes", @@ -978,7 +980,6 @@ checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" [[package]] name = "hero_job" version = "0.1.0" -source = "git+https://git.ourworld.tf/herocode/baobab.git#6c5c97e64782f7d05ff22bbafba2498f4b906463" dependencies = [ "chrono", "log", @@ -993,7 +994,7 @@ dependencies = [ [[package]] name = "hero_logger" version = "0.1.0" -source = "git+https://git.ourworld.tf/herocode/baobab.git?branch=logger#9c4fa1a78bf3cbeb57802d261ee9c9fb115ba219" +source = "git+https://git.ourworld.tf/herocode/baobab.git?branch=logger#0da7b9363c2956e6f17ac78232152c549f1d5e68" dependencies = [ "anyhow", "chrono", @@ -1010,7 +1011,6 @@ dependencies = [ [[package]] name = "hero_supervisor" version = "0.1.0" -source = "git+https://git.ourworld.tf/herocode/baobab.git#6c5c97e64782f7d05ff22bbafba2498f4b906463" dependencies = [ "anyhow", "chrono", @@ -1188,7 +1188,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.11", + "h2 0.4.12", "http 1.3.1", "http-body 1.0.1", "httparse", @@ -2459,7 +2459,7 @@ dependencies = [ [[package]] name = "reth-ipc" version = "1.6.0" -source = "git+https://github.com/paradigmxyz/reth#bf2700aa3e722a8f51b57cea9a71045da5420c1a" +source = "git+https://github.com/paradigmxyz/reth#59e4a5556fa54f1c210e45412b6a91f2351bea19" dependencies = [ "bytes", "futures", diff --git a/Cargo.toml b/Cargo.toml index 40000aa..41228d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,8 +35,11 @@ chrono = { version = "0.4", features = ["serde"] } toml = "0.8" thiserror = "1.0" async-trait = "0.1" -hero_job = { git = "https://git.ourworld.tf/herocode/baobab.git"} -baobab_actor = { git = "https://git.ourworld.tf/herocode/baobab.git"} +# hero_job = { git = "https://git.ourworld.tf/herocode/baobab.git"} +# baobab_actor = { git = "https://git.ourworld.tf/herocode/baobab.git"} +# TODO: uncomment above; only work with local paths whilst developig +hero_job = { path = "/home/maxime/baobab/core/job"} +baobab_actor = { path = "/home/maxime/baobab/core/actor"} heromodels = { git = "https://git.ourworld.tf/herocode/db.git" } heromodels_core = { git = "https://git.ourworld.tf/herocode/db.git" } heromodels-derive = { git = "https://git.ourworld.tf/herocode/db.git" } diff --git a/README.md b/README.md index 0378218..a9fe50a 100644 --- a/README.md +++ b/README.md @@ -38,4 +38,42 @@ let handle = spawn_osis_actor( - **Actor ID**: `"osis"` (constant) - **Actor Type**: `"OSIS"` - **Processing Model**: Sequential, blocking -- **Script Engine**: Rhai with OSIS-specific DSL extensions \ No newline at end of file +- **Script Engine**: Rhai with OSIS-specific DSL extensions +## Canonical Redis queues and verification + +The project uses canonical dispatch queues per script type. For OSIS, the work queue is: +- hero:q:work:type:osis + +Consumer behavior: +- The in-repo actor derives ScriptType=OSIS from its actor_id containing "osis" and BLPOPs hero:q:work:type:osis. +- This repo’s OSIS actor has been updated so its actor_id is "osis", ensuring it consumes the canonical queue. + +Quick verification (redis-cli): +- List work queues: + - KEYS hero:q:work:type:* +- Check OSIS queue length: + - LLEN hero:q:work:type:osis +- Inspect a specific job (replace {job_id} with the printed id): + - HGET hero:job:{job_id} status + - HGET hero:job:{job_id} output + +Run options: +- Option A: Run the example which spawns the OSIS actor and dispatches jobs to the canonical queue. + 1) Start Redis (if not already): redis-server + 2) In this repo: + - cargo run --example actor + 3) Observe the console: job IDs will be printed as they are created and dispatched. + 4) In a separate terminal, verify with redis-cli: + - LLEN hero:q:work:type:osis (will briefly increment, then return to 0 as the actor consumes) + - HGET hero:job:{job_id} status (should transition to started then finished) + - HGET hero:job:{job_id} output (should contain the script result) + +- Option B: Run the standalone actor binary and dispatch from another process that pushes to the canonical type queue. + 1) Start the actor: + - cargo run --bin actor_osis + 2) From any producer, LPUSH hero:q:work:type:osis {job_id} after persisting the job hash hero:job:{job_id}. + 3) Use the same redis-cli checks above to confirm consumption and completion. + +Notes: +- Hash-only result model is the default. The job result is written to hero:job:{job_id}.output and status=finished. +- Reply queues (hero:q:reply:{job_id}) are optional and not required for OSIS to function. \ No newline at end of file diff --git a/examples/actor.rs b/examples/actor.rs index ede0ee7..e84d0cd 100644 --- a/examples/actor.rs +++ b/examples/actor.rs @@ -110,9 +110,9 @@ async fn main() -> Result<(), Box> { Job::update_status(&mut redis_conn, &job.id, JobStatus::Dispatched).await?; println!("Stored job in Redis with key: {} and status: Dispatched", job_key); - // Add the job to the OSIS queue for processing - // Note: The supervisor uses "actor_queue:" prefix, so the correct queue is: - let queue_key = "hero:job:actor_queue:osis"; + // Add the job to the canonical type queue for processing + // Canonical dispatch queue per type: hero:q:work:type:{script_type} + let queue_key = "hero:q:work:type:osis"; let _: () = redis_conn.lpush(&queue_key, &job.id).await?; println!("Dispatched job {} to OSIS queue: {}", job.id, queue_key); diff --git a/examples/scripts/test_logging.rhai b/examples/scripts/test_logging.rhai new file mode 100644 index 0000000..09dbe82 --- /dev/null +++ b/examples/scripts/test_logging.rhai @@ -0,0 +1,13 @@ +// test_logging.rhai - Simple test script for logging verification + +print("=== LOGGING TEST SCRIPT ==="); +print("This is a simple test to verify Rhai logging is working"); +print("Line 1: Hello from Rhai!"); +print("Line 2: Testing print statements"); +print("Line 3: Numbers work too: " + 42); +print("Line 4: Boolean values: " + true); +print("Line 5: String concatenation: " + "works" + " " + "perfectly"); +print("=== END OF TEST ==="); + +// Return a simple value +"Logging test completed successfully" \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index bf3807b..1a23002 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -264,8 +264,8 @@ impl Actor for OSISActor { } fn actor_id(&self) -> &str { - // Use actor_queue:osis to match supervisor's dispatch queue naming - "actor_queue:osis" + // Actor ID contains "osis" so the runtime derives ScriptType=OSIS and consumes the canonical type queue. + "osis" } fn redis_url(&self) -> &str {