Skip to content

Commit

Permalink
reuse pjs code execution code (#243)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ozgunozerk and pepoviola authored Aug 28, 2024
1 parent d15f8f0 commit f8ed499
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions crates/orchestrator/src/network/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,15 +359,7 @@ impl NetworkNode {
user_types: Option<serde_json::Value>,
) -> Result<PjsResult, anyhow::Error> {
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> {
Expand Down

0 comments on commit f8ed499

Please sign in to comment.