From f8ed499450cfd2f7c4af1c6d5d983321dcb959e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCn=20=C3=96zerk?= Date: Wed, 28 Aug 2024 14:20:04 +0300 Subject: [PATCH] reuse pjs code execution code (#243) This is nothing big :) The code execution logic is already present under `pjs` function, yet it is duplicated for `pjs_file` function. This change re-uses the existing code, so that you won't have to change it twice in the future. Co-authored-by: Javier Viola <363911+pepoviola@users.noreply.github.com> --- crates/orchestrator/src/network/node.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/crates/orchestrator/src/network/node.rs b/crates/orchestrator/src/network/node.rs index 8b2ea648..fc6a5951 100644 --- a/crates/orchestrator/src/network/node.rs +++ b/crates/orchestrator/src/network/node.rs @@ -359,15 +359,7 @@ impl NetworkNode { user_types: Option, ) -> Result { let content = std::fs::read_to_string(file)?; - let code = pjs_build_template(self.ws_uri(), content.as_ref(), args, user_types); - tracing::trace!("Code to execute: {code}"); - - let value = match pjs_exec(code)? { - ReturnValue::Deserialized(val) => Ok(val), - ReturnValue::CantDeserialize(msg) => Err(msg), - }; - - Ok(value) + self.pjs(content, args, user_types).await } async fn fetch_metrics(&self) -> Result<(), anyhow::Error> {