wip
This commit is contained in:
15
core/job/README.md
Normal file
15
core/job/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
### `Job`
|
||||
Represents a script execution request with:
|
||||
- Unique ID and timestamps
|
||||
- Script content and target worker
|
||||
- Execution settings (timeout, retries, concurrency)
|
||||
- Logging configuration
|
||||
|
||||
### `JobBuilder`
|
||||
Fluent builder for configuring jobs:
|
||||
- `script()` - Set the script content
|
||||
- `worker_id()` - Target specific worker
|
||||
- `timeout()` - Set execution timeout
|
||||
- `build()` - Create the job
|
||||
- `submit()` - Fire-and-forget submission
|
||||
- `await_response()` - Submit and wait for result
|
@@ -9,32 +9,36 @@ use thiserror::Error;
|
||||
/// Redis namespace prefix for all Hero job-related keys
|
||||
pub const NAMESPACE_PREFIX: &str = "hero:job:";
|
||||
|
||||
/// Script type enumeration for different script engines
|
||||
/// Script type enumeration for different worker types
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub enum ScriptType {
|
||||
/// HeroScript - Hero's native scripting language
|
||||
HeroScript,
|
||||
/// Rhai SAL - Rhai Script Abstraction Layer
|
||||
RhaiSAL,
|
||||
/// Rhai DSL - Rhai Domain Specific Language
|
||||
RhaiDSL,
|
||||
/// OSIS - A worker that executes Rhai/HeroScript
|
||||
OSIS,
|
||||
/// SAL - A worker that executes system abstraction layer functionalities in rhai
|
||||
SAL,
|
||||
/// V - A worker that executes heroscript in V
|
||||
V,
|
||||
/// Python - A worker that executes heroscript in python
|
||||
Python,
|
||||
}
|
||||
|
||||
impl ScriptType {
|
||||
/// Get the worker queue suffix for this script type
|
||||
pub fn worker_queue_suffix(&self) -> &'static str {
|
||||
match self {
|
||||
ScriptType::HeroScript => "heroscript",
|
||||
ScriptType::RhaiSAL => "rhai_sal",
|
||||
ScriptType::RhaiDSL => "rhai_dsl",
|
||||
ScriptType::OSIS => "osis",
|
||||
ScriptType::SAL => "sal",
|
||||
ScriptType::V => "v",
|
||||
ScriptType::Python => "python",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
ScriptType::HeroScript => "heroscript",
|
||||
ScriptType::RhaiSAL => "rhai_sal",
|
||||
ScriptType::RhaiDSL => "rhai_dsl",
|
||||
ScriptType::OSIS => "osis",
|
||||
ScriptType::SAL => "sal",
|
||||
ScriptType::V => "v",
|
||||
ScriptType::Python => "python",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,9 +210,10 @@ impl Job {
|
||||
.ok_or_else(|| JobError::MissingField("script_type".to_string()))?;
|
||||
|
||||
let script_type = match script_type_str.as_str() {
|
||||
"HeroScript" => ScriptType::HeroScript,
|
||||
"RhaiSAL" => ScriptType::RhaiSAL,
|
||||
"RhaiDSL" => ScriptType::RhaiDSL,
|
||||
"OSIS" => ScriptType::OSIS,
|
||||
"SAL" => ScriptType::SAL,
|
||||
"V" => ScriptType::V,
|
||||
"Python" => ScriptType::Python,
|
||||
_ => return Err(JobError::InvalidJobData(format!("Unknown script type: {}", script_type_str))),
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user