rename worker to actor

This commit is contained in:
Timur Gordon
2025-08-05 15:44:33 +02:00
parent 5283f383b3
commit 89e953ca1d
67 changed files with 1629 additions and 1737 deletions

View File

@@ -1,6 +1,6 @@
# Hero Supervisor CLI Example
This example demonstrates how to use the `hive-supervisor` CLI tool for managing workers and jobs in the Hero ecosystem.
This example demonstrates how to use the `hive-supervisor` CLI tool for managing actors and jobs in the Hero ecosystem.
## Prerequisites
@@ -19,20 +19,20 @@ This example demonstrates how to use the `hive-supervisor` CLI tool for managing
# Follow Zinit installation instructions for your platform
```
3. **Worker Binaries**: The configuration references worker binaries that need to be available:
- `/usr/local/bin/osis_worker`
- `/usr/local/bin/sal_worker`
- `/usr/local/bin/v_worker`
- `/usr/local/bin/python_worker`
3. **Actor Binaries**: The configuration references actor binaries that need to be available:
- `/usr/local/bin/osis_actor`
- `/usr/local/bin/sal_actor`
- `/usr/local/bin/v_actor`
- `/usr/local/bin/python_actor`
For testing purposes, you can create mock worker binaries or update the paths in `config.toml` to point to existing binaries.
For testing purposes, you can create mock actor binaries or update the paths in `config.toml` to point to existing binaries.
## Configuration
The `config.toml` file contains the supervisor configuration:
- **Global settings**: Redis URL and Zinit socket path
- **Worker configurations**: Binary paths and environment variables for each worker type
- **Actor configurations**: Binary paths and environment variables for each actor type
## Usage Examples
@@ -43,29 +43,29 @@ The `config.toml` file contains the supervisor configuration:
cargo build --bin hive-supervisor --release
```
### 2. Worker Management
### 2. Actor Management
```bash
# Show help
./target/release/hive-supervisor --config examples/cli/config.toml --help
# List all configured workers
./target/release/hive-supervisor --config examples/cli/config.toml workers list
# List all configured actors
./target/release/hive-supervisor --config examples/cli/config.toml actors list
# Start all workers
./target/release/hive-supervisor --config examples/cli/config.toml workers start
# Start all actors
./target/release/hive-supervisor --config examples/cli/config.toml actors start
# Start specific workers
./target/release/hive-supervisor --config examples/cli/config.toml workers start osis_worker sal_worker
# Start specific actors
./target/release/hive-supervisor --config examples/cli/config.toml actors start osis_actor sal_actor
# Check worker status
./target/release/hive-supervisor --config examples/cli/config.toml workers status
# Check actor status
./target/release/hive-supervisor --config examples/cli/config.toml actors status
# Stop all workers
./target/release/hive-supervisor --config examples/cli/config.toml workers stop
# Stop all actors
./target/release/hive-supervisor --config examples/cli/config.toml actors stop
# Restart specific worker
./target/release/hive-supervisor --config examples/cli/config.toml workers restart osis_worker
# Restart specific actor
./target/release/hive-supervisor --config examples/cli/config.toml actors restart osis_actor
```
### 3. Job Management
@@ -73,7 +73,7 @@ cargo build --bin hive-supervisor --release
```bash
# Create a job with inline script
./target/release/hive-supervisor --config examples/cli/config.toml jobs create \
--script 'print("Hello from OSIS worker!");' \
--script 'print("Hello from OSIS actor!");' \
--script-type osis \
--caller-id "user123" \
--context-id "session456"
@@ -118,18 +118,18 @@ cargo build --bin hive-supervisor --release
```bash
# Enable debug logging
./target/release/hive-supervisor --config examples/cli/config.toml -v workers status
./target/release/hive-supervisor --config examples/cli/config.toml -v actors status
# Enable trace logging
./target/release/hive-supervisor --config examples/cli/config.toml -vv workers status
./target/release/hive-supervisor --config examples/cli/config.toml -vv actors status
# Disable timestamps
./target/release/hive-supervisor --config examples/cli/config.toml --no-timestamp workers status
./target/release/hive-supervisor --config examples/cli/config.toml --no-timestamp actors status
```
## Sample Scripts
The `sample_scripts/` directory contains example scripts for different worker types:
The `sample_scripts/` directory contains example scripts for different actor types:
- `hello_osis.rhai` - Simple OSIS/HeroScript example
- `system_sal.rhai` - SAL system operation example
@@ -148,9 +148,9 @@ The `sample_scripts/` directory contains example scripts for different worker ty
- Verify Zinit is running and the socket path is correct
- Check permissions on the socket file
3. **Worker Binary Not Found**
3. **Actor Binary Not Found**
- Update binary paths in `config.toml` to match your system
- Ensure worker binaries are executable
- Ensure actor binaries are executable
4. **Permission Denied**
- Check file permissions on configuration and binary files
@@ -161,7 +161,7 @@ The `sample_scripts/` directory contains example scripts for different worker ty
Run with verbose logging to see detailed operation information:
```bash
RUST_LOG=debug ./target/release/hive-supervisor --config examples/cli/config.toml -vv workers status
RUST_LOG=debug ./target/release/hive-supervisor --config examples/cli/config.toml -vv actors status
```
## Configuration Customization
@@ -170,15 +170,15 @@ You can customize the configuration for your environment:
1. **Update Redis URL**: Change `redis_url` in the `[global]` section
2. **Update Zinit Socket**: Change `zinit_socket_path` for your Zinit installation
3. **Worker Paths**: Update binary paths in worker sections to match your setup
4. **Environment Variables**: Add or modify environment variables for each worker type
3. **Actor Paths**: Update binary paths in actor sections to match your setup
4. **Environment Variables**: Add or modify environment variables for each actor type
## Integration with Hero Ecosystem
This CLI integrates with the broader Hero ecosystem:
- **Job Queue**: Uses Redis for job queuing and status tracking
- **Process Management**: Uses Zinit for worker lifecycle management
- **Process Management**: Uses Zinit for actor lifecycle management
- **Script Execution**: Supports multiple script types (OSIS, SAL, V, Python)
- **Monitoring**: Provides real-time status and logging capabilities

View File

@@ -1,19 +1,19 @@
# Hero Supervisor CLI Configuration Example
# This configuration demonstrates how to set up the hive-supervisor CLI
# with different worker types for script execution.
# with different actor types for script execution.
[global]
# Redis connection URL for job queuing
redis_url = "redis://localhost:6379"
# OSIS Worker Configuration
# OSIS Actor Configuration
# Handles OSIS (HeroScript) execution
[osis_worker]
[osis_actor]
binary_path = "../../../target/debug/osis"
env_vars = { "RUST_LOG" = "info", "WORKER_TYPE" = "osis", "MAX_CONCURRENT_JOBS" = "5" }
env_vars = { "RUST_LOG" = "info", "ACTOR_TYPE" = "osis", "MAX_CONCURRENT_JOBS" = "5" }
# SAL Worker Configuration
# SAL Actor Configuration
# Handles System Abstraction Layer scripts
[sal_worker]
[sal_actor]
binary_path = "../../../target/debug/sal"
env_vars = { "RUST_LOG" = "info", "WORKER_TYPE" = "sal", "MAX_CONCURRENT_JOBS" = "3" }
env_vars = { "RUST_LOG" = "info", "ACTOR_TYPE" = "sal", "MAX_CONCURRENT_JOBS" = "3" }

View File

@@ -58,25 +58,25 @@ fi
echo -e "${BLUE}=== CLI Help and Information ===${NC}"
run_cli "Show main help" --help
echo -e "${BLUE}=== Worker Management Examples ===${NC}"
run_cli "List configured workers" workers list
run_cli "Show worker management help" workers --help
echo -e "${BLUE}=== Actor Management Examples ===${NC}"
run_cli "List configured actors" actors list
run_cli "Show actor management help" actors --help
# Note: These commands would require actual worker binaries and Zinit setup
echo -e "${YELLOW}Note: The following commands require actual worker binaries and Zinit setup${NC}"
# Note: These commands would require actual actor binaries and Zinit setup
echo -e "${YELLOW}Note: The following commands require actual actor binaries and Zinit setup${NC}"
echo -e "${YELLOW}They are shown for demonstration but may fail without proper setup${NC}"
echo
# Uncomment these if you have the proper setup
# run_cli "Check worker status" workers status
# run_cli "Start all workers" workers start
# run_cli "Check worker status after start" workers status
# run_cli "Check actor status" actors status
# run_cli "Start all actors" actors start
# run_cli "Check actor status after start" actors status
echo -e "${BLUE}=== Job Management Examples ===${NC}"
run_cli "Show job management help" jobs --help
# Create sample jobs (these will also require workers to be running)
echo -e "${YELLOW}Sample job creation commands (require running workers):${NC}"
# Create sample jobs (these will also require actors to be running)
echo -e "${YELLOW}Sample job creation commands (require running actors):${NC}"
echo
echo "# Create OSIS job with inline script:"
@@ -123,22 +123,22 @@ echo
echo -e "${BLUE}=== Verbose Logging Examples ===${NC}"
echo "# Debug logging:"
echo "$CLI_BINARY --config $CONFIG_FILE -v workers list"
echo "$CLI_BINARY --config $CONFIG_FILE -v actors list"
echo
echo "# Trace logging:"
echo "$CLI_BINARY --config $CONFIG_FILE -vv workers list"
echo "$CLI_BINARY --config $CONFIG_FILE -vv actors list"
echo
echo "# No timestamps:"
echo "$CLI_BINARY --config $CONFIG_FILE --no-timestamp workers list"
echo "$CLI_BINARY --config $CONFIG_FILE --no-timestamp actors list"
echo
echo -e "${GREEN}=== Example Runner Complete ===${NC}"
echo -e "${YELLOW}To run actual commands, ensure you have:${NC}"
echo "1. Redis server running on localhost:6379"
echo "2. Zinit process manager installed and configured"
echo "3. Worker binaries available at the paths specified in config.toml"
echo "3. Actor binaries available at the paths specified in config.toml"
echo
echo -e "${YELLOW}For testing without full setup, you can:${NC}"
echo "1. Update config.toml with paths to existing binaries"
echo "2. Use the CLI help commands and configuration validation"
echo "3. Test the REPL mode (requires workers to be running)"
echo "3. Test the REPL mode (requires actors to be running)"

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""
Sample Python script for demonstration
This script demonstrates Python worker functionality
This script demonstrates Python actor functionality
"""
import json
@@ -9,7 +9,7 @@ import datetime
from typing import List, Dict
def main():
print("=== Python Worker Demo ===")
print("=== Python Actor Demo ===")
print("Python data processing operations")
# Data structures

View File

@@ -1,8 +1,8 @@
// Sample OSIS/HeroScript for demonstration
// This script demonstrates basic OSIS worker functionality
// This script demonstrates basic OSIS actor functionality
print("=== OSIS Worker Demo ===");
print("Hello from the OSIS worker!");
print("=== OSIS Actor Demo ===");
print("Hello from the OSIS actor!");
// Basic variable operations
let name = "Hero";

View File

@@ -1,12 +1,12 @@
// Sample V language script for demonstration
// This script demonstrates V worker functionality
// This script demonstrates V actor functionality
module main
import math
fn main() {
println("=== V Worker Demo ===")
println("=== V Actor Demo ===")
println("V language mathematical operations")
// Basic arithmetic

View File

@@ -1,7 +1,7 @@
// Sample SAL (System Abstraction Layer) script for demonstration
// This script demonstrates system-level operations through SAL worker
// This script demonstrates system-level operations through SAL actor
print("=== SAL Worker Demo ===");
print("=== SAL Actor Demo ===");
print("System Abstraction Layer operations");
// System information gathering