|
7 | 7 | use futures::StreamExt;
|
8 | 8 | use prost::Message;
|
9 | 9 | use std::sync::Arc;
|
| 10 | +use std::time::SystemTime; |
| 11 | +use code0_flow::flow_validator::verify_flow; |
10 | 12 | use tokio_stream::wrappers::ReceiverStream;
|
11 | 13 | use tonic::Request;
|
12 | 14 | use tonic::transport::Channel;
|
13 | 15 | use tucana::sagittarius::execution_logon_request::Data;
|
14 | 16 | use tucana::sagittarius::execution_service_client::ExecutionServiceClient;
|
15 |
| -use tucana::sagittarius::{ExecutionLogonRequest, Logon, TestExecutionResponse}; |
| 17 | +use tucana::sagittarius::{ExecutionLogonRequest, Log, Logon, TestExecutionResponse}; |
16 | 18 | use tucana::shared::{ExecutionFlow, ValidationFlow, Value};
|
17 | 19 |
|
18 | 20 | pub struct SagittariusTestExecutionServiceClient {
|
@@ -90,11 +92,38 @@ impl SagittariusTestExecutionServiceClient {
|
90 | 92 | let validation_flow = match self.load_validation_flow(request.flow_id).await {
|
91 | 93 | Some(flow) => flow,
|
92 | 94 | None => {
|
93 |
| - return; |
| 95 | + continue; |
94 | 96 | }
|
95 | 97 | };
|
96 | 98 |
|
97 | 99 | let uuid = uuid::Uuid::new_v4().to_string();
|
| 100 | + |
| 101 | + if let Some(body) = &request.body { |
| 102 | + if let Err(rule_violations) = verify_flow(validation_flow.clone(), body.clone()) { |
| 103 | + |
| 104 | + let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_millis().to_string(); |
| 105 | + let log = Log { |
| 106 | + level: "error".to_string(), |
| 107 | + timestamp: now, |
| 108 | + message: rule_violations.to_string(), |
| 109 | + }; |
| 110 | + |
| 111 | + let execution_result = ExecutionLogonRequest { |
| 112 | + data: Some(Data::Response(TestExecutionResponse { |
| 113 | + flow_id: request.flow_id, |
| 114 | + execution_uuid: uuid, |
| 115 | + result: None, |
| 116 | + logs: vec![log], |
| 117 | + })), |
| 118 | + }; |
| 119 | + |
| 120 | + if let Err(err) = tx.send(execution_result).await { |
| 121 | + log::error!("Failed to send ExecutionLogonResponse: {:?}", err); |
| 122 | + } |
| 123 | + continue |
| 124 | + } |
| 125 | + } |
| 126 | + |
98 | 127 | let execution_flow = ExecutionFlow {
|
99 | 128 | flow_id: request.flow_id,
|
100 | 129 | starting_node: validation_flow.starting_node,
|
|
0 commit comments