baobab/_archive/core/actor/cmd
2025-08-05 15:44:33 +02:00
..
osis.rs rename worker to actor 2025-08-05 15:44:33 +02:00
README.md rename worker to actor 2025-08-05 15:44:33 +02:00
system.rs rename worker to actor 2025-08-05 15:44:33 +02:00
worker.rs rename worker to actor 2025-08-05 15:44:33 +02:00

Rhai Actor Binary

A command-line actor for executing Rhai scripts from Redis task queues.

Binary: actor

Installation

Build the binary:

cargo build --bin actor --release

Usage

# Basic usage - requires circle public key
actor --circle-public-key <CIRCLE_PUBLIC_KEY>

# Custom Redis URL
actor -c <CIRCLE_PUBLIC_KEY> --redis-url redis://localhost:6379/1

# Custom actor ID and database path
actor -c <CIRCLE_PUBLIC_KEY> --actor-id my_actor --db-path /tmp/actor_db

# Preserve tasks for debugging/benchmarking
actor -c <CIRCLE_PUBLIC_KEY> --preserve-tasks

# Remove timestamps from logs
actor -c <CIRCLE_PUBLIC_KEY> --no-timestamp

# Increase verbosity
actor -c <CIRCLE_PUBLIC_KEY> -v    # Debug logging
actor -c <CIRCLE_PUBLIC_KEY> -vv   # Full debug
actor -c <CIRCLE_PUBLIC_KEY> -vvv  # Trace logging

Command-Line Options

Option Short Default Description
--circle-public-key -c Required Circle public key to listen for tasks
--redis-url -r redis://localhost:6379 Redis connection URL
--actor-id -w actor_1 Unique actor identifier
--preserve-tasks false Preserve task details after completion
--db-path actor_rhai_temp_db Database path for Rhai engine
--no-timestamp false Remove timestamps from log output
--verbose -v Increase verbosity (stackable)

Features

  • Task Queue Processing: Listens to Redis queues for Rhai script execution tasks
  • Performance Optimized: Configured for maximum Rhai engine performance
  • Graceful Shutdown: Supports shutdown signals for clean termination
  • Flexible Logging: Configurable verbosity and timestamp control
  • Database Integration: Uses heromodels for data persistence
  • Task Cleanup: Optional task preservation for debugging/benchmarking

How It Works

  1. Queue Listening: Actor listens on Redis queue baobab:{circle_public_key}
  2. Task Processing: Receives task IDs, fetches task details from Redis
  3. Script Execution: Executes Rhai scripts with configured engine
  4. Result Handling: Updates task status and sends results to reply queues
  5. Cleanup: Optionally cleans up task details after completion

Configuration Examples

Development Actor

# Simple development actor
actor -c dev_circle_123

# Development with verbose logging (no timestamps)
actor -c dev_circle_123 -v --no-timestamp

Production Actor

# Production actor with custom configuration
actor \
  --circle-public-key prod_circle_456 \
  --redis-url redis://redis-server:6379/0 \
  --actor-id prod_actor_1 \
  --db-path /var/lib/actor/db \
  --preserve-tasks

Benchmarking Actor

# Actor optimized for benchmarking
actor \
  --circle-public-key bench_circle_789 \
  --preserve-tasks \
  --no-timestamp \
  -vv

Error Handling

The actor provides clear error messages for:

  • Missing or invalid circle public key
  • Redis connection failures
  • Script execution errors
  • Database access issues

Dependencies

  • baobab_engine: Rhai engine with heromodels integration
  • redis: Redis client for task queue management
  • rhai: Script execution engine
  • clap: Command-line argument parsing
  • env_logger: Logging infrastructure