fix: resolve duplicate LogInfo type and method name issues

- Removed duplicate LogInfo type definition for WASM
- Fixed run_job client method to call 'job.run' instead of 'run_job'
- Removed unused imports (wasm_bindgen, PathBuf)
- Admin UI now builds successfully

All components working:
- OpenRPC client compiles for both native and WASM
- Admin UI builds without errors
- Method names aligned between client and server
This commit is contained in:
Timur Gordon
2025-10-27 15:42:27 +01:00
parent 674ae22f91
commit 5f5dd35dbc
4 changed files with 214 additions and 90 deletions

View File

@@ -1,22 +1,31 @@
///! Comprehensive OSIRIS + OpenRPC Example
///! Comprehensive OSIRIS + OpenRPC + Admin UI Example
///!
///! This example demonstrates:
///! 1. Starting a Hero Supervisor with OpenRPC server
///! 2. Starting an OSIRIS runner
///! 3. Registering the runner with the supervisor
///! 4. Dispatching multiple OSIRIS jobs via OpenRPC
///! 5. Monitoring job execution
///! 6. Graceful shutdown
///! 2. Building and serving the Admin UI (Yew WASM)
///! 3. Starting an OSIRIS runner
///! 4. Registering the runner with the supervisor
///! 5. Dispatching multiple OSIRIS jobs via OpenRPC
///! 6. Monitoring job execution via CLI and Web UI
///! 7. Graceful shutdown
///!
///! Services:
///! - Supervisor OpenRPC API: http://127.0.0.1:3030
///! - Admin UI: http://127.0.0.1:8080
///!
///! Usage:
///! ```bash
///! cargo run --example osiris_openrpc
///! ```
///!
///! Requirements:
///! - Redis running on localhost:6379
///! - Trunk installed (cargo install trunk)
use hero_supervisor_openrpc_client::{SupervisorClient, RunnerConfig, JobBuilder};
use hero_supervisor_openrpc_client::{SupervisorClient, JobBuilder};
use std::time::Duration;
use escargot::CargoBuild;
use std::process::Stdio;
use std::process::{Stdio, Command};
use tokio::time::sleep;
#[tokio::main]
@@ -66,9 +75,30 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
// ========================================================================
// STEP 2: Build OSIRIS runner
// STEP 2: Build and serve Admin UI
// ========================================================================
println!("\nStep 2: Building OSIRIS runner");
println!("\nStep 2: Building and serving Admin UI");
println!("─────────────────────────────────────────────────────────────\n");
let mut admin_ui = Command::new("trunk")
.arg("serve")
.arg("--port")
.arg("8080")
.arg("--address")
.arg("127.0.0.1")
.current_dir("clients/admin-ui")
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn()?;
println!("✅ Admin UI building...");
println!("🌐 Admin UI will be available at: http://127.0.0.1:8080");
sleep(Duration::from_secs(3)).await;
// ========================================================================
// STEP 3: Build OSIRIS runner
// ========================================================================
println!("\nStep 3: Building OSIRIS runner");
println!("─────────────────────────────────────────────────────────────\n");
let runner_binary = CargoBuild::new()
@@ -80,18 +110,18 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("✅ OSIRIS runner binary built");
// ========================================================================
// STEP 3: Connect OpenRPC client
// STEP 4: Connect OpenRPC client
// ========================================================================
println!("\nStep 3: Connecting OpenRPC client");
println!("\nStep 4: Connecting OpenRPC client");
println!("─────────────────────────────────────────────────────────────\n");
let client = SupervisorClient::new("http://127.0.0.1:3030")?;
println!("✅ Connected to supervisor\n");
// ========================================================================
// STEP 4: Register and start OSIRIS runner
// STEP 5: Register and start OSIRIS runner
// ========================================================================
println!("Step 4: Registering OSIRIS runner");
println!("Step 5: Registering OSIRIS runner");
println!("─────────────────────────────────────────────────────────────\n");
let runner_path = runner_binary.path().to_string_lossy();
@@ -108,9 +138,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
sleep(Duration::from_secs(2)).await;
// ========================================================================
// STEP 5: Load job scripts
// STEP 6: Load job scripts
// ========================================================================
println!("Step 5: Loading job scripts");
println!("Step 6: Loading job scripts");
println!("─────────────────────────────────────────────────────────────\n");
let note_script = std::fs::read_to_string("examples/osiris_openrpc/note.rhai")?;
@@ -121,9 +151,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("✅ Loaded 4 job scripts\n");
// ========================================================================
// STEP 6: Dispatch jobs via OpenRPC
// STEP 7: Dispatch jobs via OpenRPC
// ========================================================================
println!("Step 6: Dispatching jobs");
println!("Step 7: Dispatching jobs");
println!("─────────────────────────────────────────────────────────────\n");
// Job 1: Create Note
@@ -215,18 +245,30 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
// ========================================================================
// STEP 7: Check runner status
// STEP 8: Check runner status
// ========================================================================
println!("\nStep 7: Checking runner status");
println!("\nStep 8: Checking runner status");
println!("─────────────────────────────────────────────────────────────\n");
let status = client.get_runner_status("admin_secret", "osiris_runner").await?;
println!("Runner status: {:?}\n", status);
// ========================================================================
// STEP 8: Cleanup
// STEP 9: Keep services running for manual testing
// ========================================================================
println!("Step 8: Cleanup");
println!("\nStep 9: Services Running");
println!("─────────────────────────────────────────────────────────────\n");
println!("🌐 Admin UI: http://127.0.0.1:8080");
println!("📡 OpenRPC API: http://127.0.0.1:3030");
println!("\n⏸️ Press Ctrl+C to stop all services...\n");
// Wait for Ctrl+C
tokio::signal::ctrl_c().await?;
// ========================================================================
// STEP 10: Cleanup
// ========================================================================
println!("\n\nStep 10: Cleanup");
println!("─────────────────────────────────────────────────────────────\n");
client.stop_runner("admin_secret", "osiris_runner", false).await?;
@@ -235,6 +277,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
client.remove_runner("admin_secret", "osiris_runner").await?;
println!("✅ Runner removed");
admin_ui.kill()?;
println!("✅ Admin UI stopped");
supervisor.kill()?;
println!("✅ Supervisor stopped");