53 lines
1.9 KiB
Markdown
53 lines
1.9 KiB
Markdown
# Architecture of the `ui_repl` Crate
|
|
|
|
The `ui_repl` crate provides an interactive Read-Eval-Print Loop (REPL) interface for the rhailib ecosystem, enabling real-time script development, testing, and execution with integrated worker management.
|
|
|
|
## Core Architecture
|
|
|
|
```mermaid
|
|
graph TD
|
|
A[REPL Interface] --> B[Script Execution]
|
|
A --> C[Worker Management]
|
|
A --> D[Client Integration]
|
|
|
|
B --> B1[Local Engine Execution]
|
|
B --> B2[Remote Worker Execution]
|
|
B --> B3[Script Editing]
|
|
|
|
C --> C1[Worker Lifecycle]
|
|
C --> C2[Task Distribution]
|
|
C --> C3[Status Monitoring]
|
|
|
|
D --> D1[Redis Client]
|
|
D --> D2[Task Submission]
|
|
D --> D3[Result Retrieval]
|
|
```
|
|
|
|
## Key Features
|
|
|
|
### Interactive Development
|
|
- **Enhanced Input**: Rustyline for advanced command-line editing
|
|
- **Script Editing**: Temporary file editing with external editors
|
|
- **Syntax Highlighting**: Enhanced script development experience
|
|
|
|
### Dual Execution Modes
|
|
- **Local Execution**: Direct engine execution for development
|
|
- **Remote Execution**: Worker-based execution for production testing
|
|
- **Seamless Switching**: Easy mode transitions during development
|
|
|
|
### Integrated Worker Management
|
|
- **Worker Spawning**: Automatic worker process management
|
|
- **Lifecycle Control**: Start, stop, and restart worker processes
|
|
- **Status Monitoring**: Real-time worker health and performance
|
|
|
|
## Dependencies
|
|
|
|
- **Rhai Client**: Integration with rhailib client for remote execution
|
|
- **Rhailib Engine**: Direct engine access for local execution
|
|
- **Rhailib Worker**: Embedded worker management capabilities
|
|
- **Enhanced CLI**: Rustyline for superior REPL experience
|
|
- **Async Runtime**: Tokio for concurrent operations
|
|
|
|
## Usage Patterns
|
|
|
|
The REPL serves as the primary development interface for rhailib, providing developers with immediate feedback and testing capabilities for Rhai scripts and business logic. |