rename worker to actor
This commit is contained in:
53
core/actor/docs/ARCHITECTURE.md
Normal file
53
core/actor/docs/ARCHITECTURE.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Architecture of the `baobab_actor` Crate
|
||||
|
||||
The `baobab_actor` crate implements a distributed task execution system for Rhai scripts, providing scalable, reliable script processing through Redis-based task queues. Actors are decoupled from contexts, allowing a single actor to process tasks for multiple contexts (circles).
|
||||
|
||||
## Core Architecture
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
A[Actor Process] --> B[Task Queue Processing]
|
||||
A --> C[Script Execution Engine]
|
||||
A --> D[Result Management]
|
||||
|
||||
B --> B1[Redis Queue Monitoring]
|
||||
B --> B2[Task Deserialization]
|
||||
B --> B3[Priority Handling]
|
||||
|
||||
C --> C1[Rhai Engine Integration]
|
||||
C --> C2[Context Management]
|
||||
C --> C3[Error Handling]
|
||||
|
||||
D --> D1[Result Serialization]
|
||||
D --> D2[Reply Queue Management]
|
||||
D --> D3[Status Updates]
|
||||
```
|
||||
|
||||
## Key Components
|
||||
|
||||
### Task Processing Pipeline
|
||||
- **Queue Monitoring**: Continuous Redis queue polling for new tasks
|
||||
- **Task Execution**: Secure Rhai script execution with proper context
|
||||
- **Result Handling**: Comprehensive result and error management
|
||||
|
||||
### Engine Integration
|
||||
- **baobab Engine**: Full integration with baobab_engine for DSL access
|
||||
- **Context Injection**: Proper authentication and database context setup
|
||||
- **Security**: Isolated execution environment with access controls
|
||||
|
||||
### Scalability Features
|
||||
- **Horizontal Scaling**: Multiple actor instances for load distribution
|
||||
- **Queue-based Architecture**: Reliable task distribution via Redis
|
||||
- **Fault Tolerance**: Robust error handling and recovery mechanisms
|
||||
|
||||
## Dependencies
|
||||
|
||||
- **Redis Integration**: Task queue management and communication
|
||||
- **Rhai Engine**: Script execution with full DSL capabilities
|
||||
- **Client Integration**: Shared data structures with rhai_supervisor
|
||||
- **Heromodels**: Database and business logic integration
|
||||
- **Async Runtime**: Tokio for high-performance concurrent processing
|
||||
|
||||
## Deployment Patterns
|
||||
|
||||
Actors can be deployed as standalone processes, containerized services, or embedded components, providing flexibility for various deployment scenarios from development to production.
|
Reference in New Issue
Block a user