fix: rename overview.md files to avoid conflicts and add collection name
This commit is contained in:
@@ -229,7 +229,6 @@ impl OsirisClient {
|
||||
.context_id("command-execution")
|
||||
.runner(&self.runner_name)
|
||||
.payload(script)
|
||||
.executor("rhai")
|
||||
.timeout(self.timeout)
|
||||
.build()
|
||||
.map_err(|e| OsirisClientError::CommandFailed(format!("Failed to build job: {}", e)))?;
|
||||
|
||||
@@ -254,14 +254,12 @@ impl WasmSupervisorClient {
|
||||
pub async fn create_job_with_secret(&self, secret: String, job: hero_job::Job) -> Result<String, JsValue> {
|
||||
// Backend expects RunJobParams struct with secret and job fields - wrap in array like register_runner
|
||||
let params = serde_json::json!([{
|
||||
"secret": secret,
|
||||
"job": {
|
||||
"id": job.id,
|
||||
"caller_id": job.caller_id,
|
||||
"context_id": job.context_id,
|
||||
"payload": job.payload,
|
||||
"runner": job.runner,
|
||||
"executor": job.executor,
|
||||
"timeout": job.timeout,
|
||||
"env_vars": serde_json::from_str::<serde_json::Value>(&serde_json::to_string(&job.env_vars).unwrap_or_else(|_| "{}".to_string())).unwrap_or(serde_json::json!({})),
|
||||
"created_at": job.created_at,
|
||||
@@ -286,14 +284,12 @@ impl WasmSupervisorClient {
|
||||
pub async fn run_job(&self, secret: String, job: hero_job::Job) -> Result<String, JsValue> {
|
||||
// Backend expects RunJobParams struct with secret and job fields - wrap in array like register_runner
|
||||
let params = serde_json::json!([{
|
||||
"secret": secret,
|
||||
"job": {
|
||||
"id": job.id,
|
||||
"caller_id": job.caller_id,
|
||||
"context_id": job.context_id,
|
||||
"payload": job.payload,
|
||||
"runner": job.runner,
|
||||
"executor": job.executor,
|
||||
"timeout": job.timeout,
|
||||
"env_vars": serde_json::from_str::<serde_json::Value>(&serde_json::to_string(&job.env_vars).unwrap_or_else(|_| "{}".to_string())).unwrap_or(serde_json::json!({})),
|
||||
"created_at": job.created_at,
|
||||
@@ -369,7 +365,6 @@ impl WasmSupervisorClient {
|
||||
caller_id: String,
|
||||
context_id: String,
|
||||
payload: String,
|
||||
executor: String,
|
||||
) -> Result<String, JsValue> {
|
||||
// Generate a unique job ID
|
||||
let job_id = format!("job-{}", uuid::Uuid::new_v4());
|
||||
@@ -380,7 +375,6 @@ impl WasmSupervisorClient {
|
||||
"caller_id": caller_id,
|
||||
"context_id": context_id,
|
||||
"payload": payload,
|
||||
"executor": executor,
|
||||
"timeout": 30,
|
||||
"env": {}
|
||||
});
|
||||
@@ -416,7 +410,8 @@ impl WasmSupervisorClient {
|
||||
/// Get a job by job ID
|
||||
pub async fn get_job(&self, job_id: &str) -> Result<hero_job::Job, JsValue> {
|
||||
let params = serde_json::json!([job_id]);
|
||||
match self.call_method("get_job", params).await {
|
||||
|
||||
match self.call_method("job.run", params).await {
|
||||
Ok(result) => {
|
||||
// Convert the Job result to hero_job::Job
|
||||
if let Ok(job_value) = serde_json::from_value::<serde_json::Value>(result) {
|
||||
@@ -426,7 +421,6 @@ impl WasmSupervisorClient {
|
||||
let context_id = job_value.get("context_id").and_then(|v| v.as_str()).unwrap_or("").to_string();
|
||||
let payload = job_value.get("payload").and_then(|v| v.as_str()).unwrap_or("").to_string();
|
||||
let runner = job_value.get("runner").and_then(|v| v.as_str()).unwrap_or("").to_string();
|
||||
let executor = job_value.get("executor").and_then(|v| v.as_str()).unwrap_or("").to_string();
|
||||
let timeout_secs = job_value.get("timeout").and_then(|v| v.get("secs")).and_then(|v| v.as_u64()).unwrap_or(30);
|
||||
let env_vars = job_value.get("env_vars").map(|v| v.to_string()).unwrap_or_else(|| "{}".to_string());
|
||||
let created_at = job_value.get("created_at").and_then(|v| v.as_str()).unwrap_or("").to_string();
|
||||
@@ -438,7 +432,6 @@ impl WasmSupervisorClient {
|
||||
context_id,
|
||||
payload,
|
||||
runner,
|
||||
executor,
|
||||
timeout: timeout_secs,
|
||||
env_vars: serde_json::from_str(&env_vars).unwrap_or_default(),
|
||||
created_at: chrono::DateTime::parse_from_rfc3339(&created_at)
|
||||
@@ -830,7 +823,6 @@ pub fn create_job_canonical_repr(
|
||||
context_id: String,
|
||||
payload: String,
|
||||
runner: String,
|
||||
executor: String,
|
||||
timeout: u64,
|
||||
env_vars_json: String,
|
||||
) -> Result<String, JsValue> {
|
||||
@@ -844,13 +836,12 @@ pub fn create_job_canonical_repr(
|
||||
|
||||
// Create canonical representation (matches Job::canonical_representation in runner_rust)
|
||||
let canonical = format!(
|
||||
"{}:{}:{}:{}:{}:{}:{}:{:?}",
|
||||
"{}:{}:{}:{}:{}:{}:{:?}",
|
||||
id,
|
||||
caller_id,
|
||||
context_id,
|
||||
payload,
|
||||
runner,
|
||||
executor,
|
||||
timeout,
|
||||
env_vars_sorted
|
||||
);
|
||||
|
||||
@@ -73,7 +73,6 @@ pub struct Job {
|
||||
pub context_id: String,
|
||||
pub payload: String,
|
||||
pub runner: String, // name of the runner to execute this job
|
||||
pub executor: String, // name of the executor the runner will use to execute this job
|
||||
pub timeout: u64, // timeout in seconds
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen(skip))]
|
||||
pub env_vars: HashMap<String, String>, // environment variables for script execution
|
||||
@@ -109,7 +108,6 @@ impl Job {
|
||||
context_id: String,
|
||||
payload: String,
|
||||
runner: String,
|
||||
executor: String,
|
||||
) -> Self {
|
||||
let now = Utc::now();
|
||||
Self {
|
||||
@@ -118,7 +116,6 @@ impl Job {
|
||||
context_id,
|
||||
payload,
|
||||
runner,
|
||||
executor,
|
||||
timeout: 300, // 5 minutes default
|
||||
env_vars: HashMap::new(),
|
||||
created_at: now,
|
||||
@@ -137,13 +134,12 @@ impl Job {
|
||||
env_vars_sorted.sort_by_key(|&(k, _)| k);
|
||||
|
||||
format!(
|
||||
"{}:{}:{}:{}:{}:{}:{}:{:?}",
|
||||
"{}:{}:{}:{}:{}:{}:{:?}",
|
||||
self.id,
|
||||
self.caller_id,
|
||||
self.context_id,
|
||||
self.payload,
|
||||
self.runner,
|
||||
self.executor,
|
||||
self.timeout,
|
||||
env_vars_sorted
|
||||
)
|
||||
@@ -202,7 +198,6 @@ pub struct JobBuilder {
|
||||
context_id: String,
|
||||
payload: String,
|
||||
runner: String,
|
||||
executor: String,
|
||||
timeout: u64, // timeout in seconds
|
||||
env_vars: HashMap<String, String>,
|
||||
signatures: Vec<JobSignature>,
|
||||
@@ -215,7 +210,6 @@ impl JobBuilder {
|
||||
context_id: "".to_string(),
|
||||
payload: "".to_string(),
|
||||
runner: "".to_string(),
|
||||
executor: "".to_string(),
|
||||
timeout: 300, // 5 minutes default
|
||||
env_vars: HashMap::new(),
|
||||
signatures: Vec::new(),
|
||||
@@ -246,11 +240,6 @@ impl JobBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the executor for this job
|
||||
pub fn executor(mut self, executor: &str) -> Self {
|
||||
self.executor = executor.to_string();
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the timeout for job execution (in seconds)
|
||||
pub fn timeout(mut self, timeout: u64) -> Self {
|
||||
@@ -311,16 +300,12 @@ impl JobBuilder {
|
||||
if self.runner.is_empty() {
|
||||
return Err(JobError::InvalidData("runner is required".to_string()));
|
||||
}
|
||||
if self.executor.is_empty() {
|
||||
return Err(JobError::InvalidData("executor is required".to_string()));
|
||||
}
|
||||
|
||||
let mut job = Job::new(
|
||||
self.caller_id,
|
||||
self.context_id,
|
||||
self.payload,
|
||||
self.runner,
|
||||
self.executor,
|
||||
);
|
||||
|
||||
job.timeout = self.timeout;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Runner trait abstraction for job processing
|
||||
|
||||
use crate::{Job, JobStatus, Client};
|
||||
use log::{debug, error, info};
|
||||
use log::{error, info};
|
||||
use redis::AsyncCommands;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -32,7 +32,6 @@ where
|
||||
.caller_id("script_mode")
|
||||
.payload(script_content)
|
||||
.runner(runner_id)
|
||||
.executor("rhai")
|
||||
.timeout(job_timeout.as_secs())
|
||||
.build()?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user