wip
This commit is contained in:
@@ -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