Add get_error method to client for standardized error retrieval
- Implemented get_error() method to fetch job error messages from Redis - Mirrors get_result() pattern for consistency - Used by supervisor to retrieve job errors without manual Redis queries - Cleanup: removed old runner_osis directory
This commit is contained in:
@@ -9,9 +9,7 @@ use crate::runner_trait::Runner;
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SyncRunnerConfig {
|
||||
pub runner_id: String,
|
||||
pub db_path: String,
|
||||
pub redis_url: String,
|
||||
pub preserve_tasks: bool,
|
||||
}
|
||||
|
||||
/// Synchronous runner that processes jobs sequentially
|
||||
@@ -39,11 +37,9 @@ impl SyncRunner {
|
||||
fn execute_job_with_engine(
|
||||
engine: &mut Engine,
|
||||
job: &Job,
|
||||
db_path: &str,
|
||||
) -> Result<Dynamic, Box<rhai::EvalAltResult>> {
|
||||
// Set up job context in the engine
|
||||
let mut db_config = rhai::Map::new();
|
||||
db_config.insert("DB_PATH".into(), db_path.to_string().into());
|
||||
db_config.insert("CALLER_ID".into(), job.caller_id.clone().into());
|
||||
db_config.insert("CONTEXT_ID".into(), job.context_id.clone().into());
|
||||
|
||||
@@ -53,12 +49,6 @@ impl SyncRunner {
|
||||
job.signatures.iter()
|
||||
.map(|sig| Dynamic::from(sig.public_key.clone()))
|
||||
.collect()
|
||||
} else if let Some(sig_json) = job.env_vars.get("SIGNATORIES") {
|
||||
// Fall back to SIGNATORIES from env_vars (for backward compatibility)
|
||||
match serde_json::from_str::<Vec<String>>(sig_json) {
|
||||
Ok(sigs) => sigs.into_iter().map(Dynamic::from).collect(),
|
||||
Err(_) => Vec::new(),
|
||||
}
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
@@ -87,7 +77,7 @@ impl Runner for SyncRunner {
|
||||
let mut engine = (self.engine_factory)();
|
||||
|
||||
// Execute the script
|
||||
match Self::execute_job_with_engine(&mut engine, &job, &self.config.db_path) {
|
||||
match Self::execute_job_with_engine(&mut engine, &job) {
|
||||
Ok(result) => {
|
||||
let output_str = if result.is::<String>() {
|
||||
result.into_string().unwrap()
|
||||
@@ -121,10 +111,8 @@ impl Runner for SyncRunner {
|
||||
/// Convenience function to spawn a synchronous runner using the trait interface
|
||||
pub fn spawn_sync_runner<F>(
|
||||
runner_id: String,
|
||||
db_path: String,
|
||||
redis_url: String,
|
||||
shutdown_rx: tokio::sync::mpsc::Receiver<()>,
|
||||
preserve_tasks: bool,
|
||||
engine_factory: F,
|
||||
) -> tokio::task::JoinHandle<Result<(), Box<dyn std::error::Error + Send + Sync>>>
|
||||
where
|
||||
@@ -132,9 +120,7 @@ where
|
||||
{
|
||||
let config = SyncRunnerConfig {
|
||||
runner_id,
|
||||
db_path,
|
||||
redis_url,
|
||||
preserve_tasks,
|
||||
};
|
||||
|
||||
let runner = Arc::new(SyncRunner::new(config, engine_factory));
|
||||
|
||||
Reference in New Issue
Block a user