diff --git a/core/actor/src/lib.rs b/core/actor/src/lib.rs index b34d308..971d141 100644 --- a/core/actor/src/lib.rs +++ b/core/actor/src/lib.rs @@ -119,24 +119,21 @@ async fn execute_script_and_update_status( /// and evaluates the script. It returns the result or error without updating Redis. /// This allows actors to handle Redis updates according to their own patterns. pub async fn execute_job_with_engine( - engine: &Engine, + engine: &mut Engine, job: &Job, db_path: &str, ) -> Result> { - // Clone the engine to avoid mutating the original - let mut engine_clone = engine.clone(); - // 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()); - engine_clone.set_default_tag(Dynamic::from(db_config)); + engine.set_default_tag(Dynamic::from(db_config)); debug!("Actor for Context ID '{}': Evaluating script with Rhai engine (job context set).", job.context_id); // Execute the script with the configured engine - engine_clone.eval::(&job.script) + engine.eval::(&job.script) } /// Clean up job from Redis if preserve_tasks is false @@ -262,6 +259,3 @@ pub fn spawn_rhai_actor( // Re-export the main trait-based interface for convenience pub use actor_trait::{Actor, ActorConfig, spawn_actor}; -// Re-export the shared job execution function -pub use execute_job_with_engine; -