rename rhai client to dispatcher

This commit is contained in:
Timur Gordon
2025-07-09 23:39:48 +02:00
parent d059af9a18
commit 29ff40d1a4
19 changed files with 205 additions and 136 deletions

View File

@@ -521,7 +521,7 @@ dependencies = [
"env_logger",
"log",
"redis",
"rhai_client",
"rhai_dispatcher",
"serde",
"serde_json",
"tokio",
@@ -1669,7 +1669,7 @@ dependencies = [
]
[[package]]
name = "rhai_client"
name = "rhai_dispatcher"
version = "0.1.0"
dependencies = [
"chrono",
@@ -2514,7 +2514,7 @@ dependencies = [
"log",
"redis",
"rhai",
"rhai_client",
"rhai_dispatcher",
"serde",
"serde_json",
"tokio",

View File

@@ -28,7 +28,7 @@ rhai = "1.18.0"
heromodels = { path = "../../../db/heromodels" }
rhailib_engine = { path = "../../../rhailib/src/engine" }
rhailib_worker = { path = "../../../rhailib/src/worker" }
rhai_client = { path = "../../../rhailib/src/client" }
rhai_dispatcher = { path = "../../../rhailib/src/dispatcher" }
ourdb = { path = "../../../db/ourdb" } # Added for IdSequence
sal-service-manager = { path = "../../../sal/service_manager" }
tokio-tungstenite = "0.23"

View File

@@ -128,7 +128,7 @@ When a circle configuration includes an initialization script:
1. Worker starts and connects to Redis
2. Launcher waits 2 seconds for worker startup
3. Launcher sends script content via RhaiClient to worker's queue
3. Launcher sends script content via RhaiDispatcher to worker's queue
4. Worker executes the initialization script
## Configuration

View File

@@ -42,7 +42,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Wait a moment for the launcher to start services
tokio::time::sleep(Duration::from_secs(5)).await;
let client = rhai_client::RhaiClientBuilder::new()
let client = rhai_dispatcher::RhaiDispatcherBuilder::new()
.redis_url(REDIS_URL)
.caller_id("test_launcher")
.build()?;
@@ -78,7 +78,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.await?;
println!("Received task details: {:?}", task_details_caller_pk);
assert_eq!(task_details_caller_pk.status, "completed");
// The caller should be "launcher" as set in the RhaiClient
// The caller should be "launcher" as set in the RhaiDispatcher
println!("✅ SUCCESS: Worker correctly reported CALLER_PUBLIC_KEY for init script.");
// Test 3: Simple script execution

View File

@@ -1,5 +1,5 @@
use log::{info, debug};
use rhai_client::RhaiClientBuilder;
use rhai_dispatcher::RhaiDispatcherBuilder;
use sal_service_manager::{ServiceConfig as ServiceManagerConfig, ServiceStatus};
use std::sync::{Arc, Mutex};
@@ -217,8 +217,8 @@ async fn send_init_script_to_worker(
) -> Result<(), Box<dyn std::error::Error>> {
println!("Sending initialization script '{}' to worker for circle: {}", init_script, public_key);
// Create RhaiClient and send script
let client = RhaiClientBuilder::new()
// Create RhaiDispatcher and send script
let client = RhaiDispatcherBuilder::new()
.redis_url(redis_url)
.caller_id("launcher")
.build()?;