remove separate implementation of job api from coordinator
This commit is contained in:
@@ -200,41 +200,8 @@ impl FlowCreate {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct JobCreate {
|
||||
pub id: u32,
|
||||
pub caller_id: u32,
|
||||
pub context_id: u32,
|
||||
pub script: String,
|
||||
pub runner: Option<String>,
|
||||
pub timeout: u32,
|
||||
pub retries: u8,
|
||||
pub env_vars: HashMap<String, String>,
|
||||
pub prerequisites: Vec<String>,
|
||||
pub depends: Vec<u32>,
|
||||
}
|
||||
|
||||
impl JobCreate {
|
||||
pub fn into_domain(self) -> Job {
|
||||
use chrono::Utc;
|
||||
|
||||
// Convert old format to hero_job::Job
|
||||
// Note: depends and prerequisites are workflow fields that need separate storage
|
||||
Job {
|
||||
id: self.id.to_string(),
|
||||
caller_id: self.caller_id.to_string(),
|
||||
context_id: self.context_id.to_string(),
|
||||
payload: self.script,
|
||||
runner: self.runner.unwrap_or_else(|| "default-runner".to_string()),
|
||||
timeout: self.timeout as u64,
|
||||
env_vars: self.env_vars,
|
||||
created_at: Utc::now(),
|
||||
updated_at: Utc::now(),
|
||||
signatures: Vec::new(),
|
||||
}
|
||||
// TODO: Store depends and prerequisites separately in JobSummary/DAG
|
||||
}
|
||||
}
|
||||
// JobCreate removed - coordinator only manages flows, not individual jobs
|
||||
// Jobs should be created by the supervisor or other services
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct MessageCreate {
|
||||
@@ -247,40 +214,31 @@ pub struct MessageCreate {
|
||||
pub timeout: u32,
|
||||
pub timeout_ack: u32,
|
||||
pub timeout_result: u32,
|
||||
pub job: Vec<JobCreate>,
|
||||
// Jobs removed - use flow nodes instead
|
||||
}
|
||||
impl MessageCreate {
|
||||
pub fn into_domain(self) -> Message {
|
||||
use crate::time::current_timestamp;
|
||||
|
||||
let ts = current_timestamp();
|
||||
|
||||
let MessageCreate {
|
||||
id,
|
||||
caller_id,
|
||||
context_id,
|
||||
message,
|
||||
message_type,
|
||||
message_format_type,
|
||||
timeout,
|
||||
timeout_ack,
|
||||
timeout_result,
|
||||
job,
|
||||
} = self;
|
||||
|
||||
|
||||
// Convert to Message
|
||||
// Note: flow_id is set to 0 for now, should be set by the caller
|
||||
Message {
|
||||
id,
|
||||
caller_id,
|
||||
context_id,
|
||||
flow_id: 0, // TODO: MessageCreate should include flow_id
|
||||
message,
|
||||
message_type,
|
||||
message_format_type,
|
||||
timeout,
|
||||
timeout_ack,
|
||||
timeout_result,
|
||||
id: self.id,
|
||||
caller_id: self.caller_id,
|
||||
context_id: self.context_id,
|
||||
flow_id: 0, // TODO: Get from params or context
|
||||
message: self.message,
|
||||
message_type: self.message_type,
|
||||
message_format_type: self.message_format_type,
|
||||
timeout: self.timeout,
|
||||
timeout_ack: self.timeout_ack,
|
||||
timeout_result: self.timeout_result,
|
||||
transport_id: None,
|
||||
transport_status: None,
|
||||
nodes: Vec::new(), // TODO: MessageCreate should include nodes
|
||||
job: job.into_iter().map(JobCreate::into_domain).collect(),
|
||||
job: Vec::new(), // Jobs removed - coordinator only manages flows
|
||||
logs: Vec::new(),
|
||||
created_at: ts,
|
||||
updated_at: ts,
|
||||
@@ -330,17 +288,7 @@ pub struct FlowLoadParams {
|
||||
pub id: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct JobCreateParams {
|
||||
pub context_id: u32,
|
||||
pub job: JobCreate,
|
||||
}
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct JobLoadParams {
|
||||
pub context_id: u32,
|
||||
pub caller_id: u32,
|
||||
pub id: u32,
|
||||
}
|
||||
// JobCreateParams and JobLoadParams removed - coordinator only manages flows
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct MessageCreateParams {
|
||||
@@ -506,42 +454,8 @@ pub fn build_module(state: Arc<AppState>) -> RpcModule<()> {
|
||||
.expect("register flow.start");
|
||||
}
|
||||
|
||||
// Job
|
||||
{
|
||||
let state = state.clone();
|
||||
module
|
||||
.register_async_method("job.create", move |params, _caller, _ctx| {
|
||||
let state = state.clone();
|
||||
async move {
|
||||
let p: JobCreateParams = params.parse().map_err(invalid_params_err)?;
|
||||
let job = p.job.into_domain();
|
||||
let job = state
|
||||
.service
|
||||
.create_job(p.context_id, job)
|
||||
.await
|
||||
.map_err(storage_err)?;
|
||||
Ok::<_, ErrorObjectOwned>(job)
|
||||
}
|
||||
})
|
||||
.expect("register job.create");
|
||||
}
|
||||
{
|
||||
let state = state.clone();
|
||||
module
|
||||
.register_async_method("job.load", move |params, _caller, _ctx| {
|
||||
let state = state.clone();
|
||||
async move {
|
||||
let p: JobLoadParams = params.parse().map_err(invalid_params_err)?;
|
||||
let job = state
|
||||
.service
|
||||
.load_job(p.context_id, p.caller_id, p.id)
|
||||
.await
|
||||
.map_err(storage_err)?;
|
||||
Ok::<_, ErrorObjectOwned>(job)
|
||||
}
|
||||
})
|
||||
.expect("register job.load");
|
||||
}
|
||||
// Job endpoints removed - coordinator only manages flows
|
||||
// Jobs should be created and managed by the supervisor
|
||||
|
||||
// Message
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user