This commit is contained in:
Timur Gordon
2025-08-01 00:01:08 +02:00
parent 32c2cbe0cc
commit 8ed40ce99c
57 changed files with 2047 additions and 4113 deletions

View File

@@ -1,7 +1,7 @@
use crate::Server;
use actix::prelude::*;
use actix_web_actors::ws;
use hero_dispatcher::{Dispatcher, ScriptType};
use hero_supervisor::{Supervisor, ScriptType};
use serde_json::{json, Value};
use std::time::Duration;
@@ -82,7 +82,7 @@ impl Server {
}
};
let dispatcher = match self.dispatcher.clone() {
let supervisor = match self.supervisor.clone() {
Some(d) => d,
None => {
let err_resp = JsonRpcResponse {
@@ -90,7 +90,7 @@ impl Server {
result: None,
error: Some(JsonRpcError {
code: -32603,
message: "Internal error: dispatcher not available".to_string(),
message: "Internal error: supervisor not available".to_string(),
data: None,
}),
id: client_rpc_id,
@@ -102,7 +102,7 @@ impl Server {
let client_rpc_id_clone = client_rpc_id.clone();
let fut = async move {
dispatcher.start_job(&job_id).await
supervisor.start_job(&job_id).await
};
ctx.spawn(
@@ -190,7 +190,7 @@ impl Server {
}
};
let dispatcher = match self.dispatcher.clone() {
let supervisor = match self.supervisor.clone() {
Some(d) => d,
None => {
let err_resp = JsonRpcResponse {
@@ -198,7 +198,7 @@ impl Server {
result: None,
error: Some(JsonRpcError {
code: -32603,
message: "Internal error: dispatcher not available".to_string(),
message: "Internal error: supervisor not available".to_string(),
data: None,
}),
id: client_rpc_id,
@@ -210,7 +210,7 @@ impl Server {
let client_rpc_id_clone = client_rpc_id.clone();
let fut = async move {
dispatcher.get_job_status(&job_id).await
supervisor.get_job_status(&job_id).await
};
ctx.spawn(
@@ -279,7 +279,7 @@ impl Server {
return;
}
let dispatcher = match self.dispatcher.clone() {
let supervisor = match self.supervisor.clone() {
Some(d) => d,
None => {
let err_resp = JsonRpcResponse {
@@ -287,7 +287,7 @@ impl Server {
result: None,
error: Some(JsonRpcError {
code: -32603,
message: "Internal error: dispatcher not available".to_string(),
message: "Internal error: supervisor not available".to_string(),
data: None,
}),
id: client_rpc_id,
@@ -299,7 +299,7 @@ impl Server {
let client_rpc_id_clone = client_rpc_id.clone();
let fut = async move {
dispatcher.list_jobs().await
supervisor.list_jobs().await
};
ctx.spawn(
@@ -403,7 +403,7 @@ impl Server {
}
};
let dispatcher = match self.dispatcher.clone() {
let supervisor = match self.supervisor.clone() {
Some(d) => d,
None => {
let err_resp = JsonRpcResponse {
@@ -411,7 +411,7 @@ impl Server {
result: None,
error: Some(JsonRpcError {
code: -32603,
message: "Internal error: dispatcher not available".to_string(),
message: "Internal error: supervisor not available".to_string(),
data: None,
}),
id: client_rpc_id,
@@ -423,7 +423,7 @@ impl Server {
let client_rpc_id_clone = client_rpc_id.clone();
let fut = async move {
dispatcher
supervisor
.new_job()
.context_id(&circle_pk)
.script_type(ScriptType::RhaiSAL)
@@ -518,7 +518,7 @@ impl Server {
}
};
let dispatcher = match self.dispatcher.clone() {
let supervisor = match self.supervisor.clone() {
Some(d) => d,
None => {
let err_resp = JsonRpcResponse {
@@ -526,7 +526,7 @@ impl Server {
result: None,
error: Some(JsonRpcError {
code: -32603,
message: "Internal error: dispatcher not available".to_string(),
message: "Internal error: supervisor not available".to_string(),
data: None,
}),
id: client_rpc_id,
@@ -538,7 +538,7 @@ impl Server {
let client_rpc_id_clone = client_rpc_id.clone();
let fut = async move {
dispatcher.get_job_output(&job_id).await
supervisor.get_job_output(&job_id).await
};
ctx.spawn(
@@ -625,7 +625,7 @@ impl Server {
}
};
let dispatcher = match self.dispatcher.clone() {
let supervisor = match self.supervisor.clone() {
Some(d) => d,
None => {
let err_resp = JsonRpcResponse {
@@ -633,7 +633,7 @@ impl Server {
result: None,
error: Some(JsonRpcError {
code: -32603,
message: "Internal error: dispatcher not available".to_string(),
message: "Internal error: supervisor not available".to_string(),
data: None,
}),
id: client_rpc_id,
@@ -645,7 +645,7 @@ impl Server {
let client_rpc_id_clone = client_rpc_id.clone();
let fut = async move {
dispatcher.get_job_logs(&job_id).await
supervisor.get_job_logs(&job_id).await
};
ctx.spawn(
@@ -733,7 +733,7 @@ impl Server {
}
};
let dispatcher = match self.dispatcher.clone() {
let supervisor = match self.supervisor.clone() {
Some(d) => d,
None => {
let err_resp = JsonRpcResponse {
@@ -741,7 +741,7 @@ impl Server {
result: None,
error: Some(JsonRpcError {
code: -32603,
message: "Internal error: dispatcher not available".to_string(),
message: "Internal error: supervisor not available".to_string(),
data: None,
}),
id: client_rpc_id,
@@ -753,7 +753,7 @@ impl Server {
let client_rpc_id_clone = client_rpc_id.clone();
let fut = async move {
dispatcher.stop_job(&job_id).await
supervisor.stop_job(&job_id).await
};
ctx.spawn(
@@ -840,7 +840,7 @@ impl Server {
}
};
let dispatcher = match self.dispatcher.clone() {
let supervisor = match self.supervisor.clone() {
Some(d) => d,
None => {
let err_resp = JsonRpcResponse {
@@ -848,7 +848,7 @@ impl Server {
result: None,
error: Some(JsonRpcError {
code: -32603,
message: "Internal error: dispatcher not available".to_string(),
message: "Internal error: supervisor not available".to_string(),
data: None,
}),
id: client_rpc_id,
@@ -860,7 +860,7 @@ impl Server {
let client_rpc_id_clone = client_rpc_id.clone();
let fut = async move {
dispatcher.delete_job(&job_id).await
supervisor.delete_job(&job_id).await
};
ctx.spawn(
@@ -929,7 +929,7 @@ impl Server {
return;
}
let dispatcher = match self.dispatcher.clone() {
let supervisor = match self.supervisor.clone() {
Some(d) => d,
None => {
let err_resp = JsonRpcResponse {
@@ -937,7 +937,7 @@ impl Server {
result: None,
error: Some(JsonRpcError {
code: -32603,
message: "Internal error: dispatcher not available".to_string(),
message: "Internal error: supervisor not available".to_string(),
data: None,
}),
id: client_rpc_id,
@@ -949,7 +949,7 @@ impl Server {
let client_rpc_id_clone = client_rpc_id.clone();
let fut = async move {
dispatcher.clear_all_jobs().await
supervisor.clear_all_jobs().await
};
ctx.spawn(