Update OsirisClient to use unified JobBuilder for both native and WASM
- Use hero_supervisor_openrpc_client::JobBuilder for both native and WASM builds - Simplified execute_script method by removing duplicate job building code - JobBuilder now works consistently across platforms - Removed separate WasmJobBuilder usage
This commit is contained in:
@@ -211,20 +211,26 @@ impl OsirisClient {
|
|||||||
let secret = self.supervisor_secret.as_ref()
|
let secret = self.supervisor_secret.as_ref()
|
||||||
.ok_or_else(|| OsirisClientError::ConfigError("supervisor_secret not configured for commands".to_string()))?;
|
.ok_or_else(|| OsirisClientError::ConfigError("supervisor_secret not configured for commands".to_string()))?;
|
||||||
|
|
||||||
// Use supervisor client for native builds
|
// Use unified JobBuilder for both native and WASM
|
||||||
|
use hero_supervisor_openrpc_client::JobBuilder;
|
||||||
|
|
||||||
|
let job = JobBuilder::new()
|
||||||
|
.caller_id("osiris-client")
|
||||||
|
.context_id("command-execution")
|
||||||
|
.payload(script)
|
||||||
|
.runner(&self.runner_name)
|
||||||
|
.executor("rhai")
|
||||||
|
.timeout(self.timeout)
|
||||||
|
.build()
|
||||||
|
.map_err(|e| OsirisClientError::CommandFailed(e.to_string()))?;
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
{
|
{
|
||||||
use hero_supervisor_openrpc_client::{SupervisorClient, JobBuilder};
|
use hero_supervisor_openrpc_client::SupervisorClient;
|
||||||
|
|
||||||
let supervisor_client = SupervisorClient::new(supervisor_url)
|
let supervisor_client = SupervisorClient::new(supervisor_url)
|
||||||
.map_err(|e| OsirisClientError::CommandFailed(e.to_string()))?;
|
.map_err(|e| OsirisClientError::CommandFailed(e.to_string()))?;
|
||||||
|
|
||||||
let job = JobBuilder::new()
|
|
||||||
.runner_name(&self.runner_name)
|
|
||||||
.script(script)
|
|
||||||
.timeout(self.timeout)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let result = supervisor_client.run_job(secret, job)
|
let result = supervisor_client.run_job(secret, job)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| OsirisClientError::CommandFailed(e.to_string()))?;
|
.map_err(|e| OsirisClientError::CommandFailed(e.to_string()))?;
|
||||||
@@ -243,19 +249,12 @@ impl OsirisClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use WASM client for browser builds
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
{
|
{
|
||||||
use hero_supervisor_openrpc_client::wasm::{WasmSupervisorClient, WasmJobBuilder};
|
use hero_supervisor_openrpc_client::wasm::WasmSupervisorClient;
|
||||||
|
|
||||||
let supervisor_client = WasmSupervisorClient::new(supervisor_url.clone());
|
let supervisor_client = WasmSupervisorClient::new(supervisor_url.clone());
|
||||||
|
|
||||||
let job = WasmJobBuilder::new()
|
|
||||||
.runner_name(&self.runner_name)
|
|
||||||
.script(script)
|
|
||||||
.timeout(self.timeout as i32)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let result_str = supervisor_client.run_job(secret.clone(), job)
|
let result_str = supervisor_client.run_job(secret.clone(), job)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| OsirisClientError::CommandFailed(format!("{:?}", e)))?;
|
.map_err(|e| OsirisClientError::CommandFailed(format!("{:?}", e)))?;
|
||||||
|
|||||||
Reference in New Issue
Block a user