cleanup and refactor

This commit is contained in:
Timur Gordon
2025-11-13 14:41:30 +01:00
parent 4b516d9d7e
commit 2625534152
29 changed files with 2662 additions and 3276 deletions

View File

@@ -23,39 +23,24 @@ tokio = { version = "1.0", features = ["full"] }
## Quick Start
```rust
use hero_supervisor_openrpc_client::{
SupervisorClient, RunnerConfig, RunnerType, ProcessManagerType, JobBuilder, JobType
};
use std::path::PathBuf;
use std::time::Duration;
use hero_supervisor_openrpc_client::{SupervisorClient, JobBuilder};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a client
let client = SupervisorClient::new("http://127.0.0.1:3030")?;
// Create a client with admin secret
let client = SupervisorClient::new("http://127.0.0.1:3030", "your-admin-secret")?;
// Add a runner
let config = RunnerConfig {
actor_id: "my_actor".to_string(),
runner_type: RunnerType::OSISRunner,
binary_path: PathBuf::from("/path/to/actor/binary"),
db_path: "/path/to/db".to_string(),
redis_url: "redis://localhost:6379".to_string(),
};
// Register a runner (runner must be started externally)
client.register_runner("admin-secret", "my_runner").await?;
client.add_runner(config, ProcessManagerType::Simple).await?;
// Start the runner
client.start_runner("my_actor").await?;
// Create and queue a job
// Create and run a job
let job = JobBuilder::new()
.caller_id("my_client")
.context_id("example_context")
.payload("print('Hello from Hero Supervisor!');")
.job_type(JobType::OSIS)
.runner("my_actor")
.timeout(Duration::from_secs(60))
.payload("echo 'Hello from Hero Supervisor!'")
.executor("bash")
.runner("my_runner")
.timeout(60)
.build()?;
client.queue_job_to_runner("my_actor", job).await?;
@@ -83,11 +68,11 @@ let client = SupervisorClient::new("http://127.0.0.1:3030")?;
### Runner Management
```rust
// Add a runner
client.add_runner(config, ProcessManagerType::Simple).await?;
// Register a runner
client.register_runner("admin-secret", "my_runner").await?;
// Remove a runner
client.remove_runner("actor_id").await?;
client.remove_runner("admin-secret", "my_runner").await?;
// List all runners
let runners = client.list_runners().await?;
@@ -150,10 +135,9 @@ let statuses = client.get_all_runner_status().await?;
- `V` - V job type
- `Python` - Python job type
### ProcessManagerType
### Runner Management
- `Simple` - Direct process spawning
- `Tmux(String)` - Tmux session-based management
Runners are expected to be started and managed externally. The supervisor only tracks which runners are registered and queues jobs to them via Redis.
### ProcessStatus