Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions crates/taurus-core/src/runtime/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1194,9 +1194,9 @@ mod tests {
"rest::control::respond",
vec![
literal_param(100, "http_status_code", int_value(200)),
literal_param(101, "headers", empty_struct_value()),
literal_param(102, "http_schema", string_value("application/json")),
literal_param(103, "payload", string_value("hello")),
literal_param(101, "headers", empty_struct_value()),
],
None,
);
Expand All @@ -1212,15 +1212,15 @@ mod tests {
assert_eq!(node_result.parameter_results[0].value, Some(int_value(200)));
assert_eq!(
node_result.parameter_results[1].value,
Some(empty_struct_value())
Some(string_value("application/json"))
);
assert_eq!(
node_result.parameter_results[2].value,
Some(string_value("application/json"))
Some(string_value("hello"))
);
assert_eq!(
node_result.parameter_results[3].value,
Some(string_value("hello"))
Some(empty_struct_value())
);
assert!(matches!(
node_result.result,
Expand Down Expand Up @@ -1438,9 +1438,9 @@ mod tests {
"rest::control::respond",
vec![
literal_param(1, "http_status_code", int_value(200)),
literal_param(2, "headers", empty_struct_value()),
literal_param(3, "http_schema", string_value("text/plain")),
literal_param(4, "payload", string_value("20")),
literal_param(2, "headers", empty_struct_value()),
],
None,
);
Expand Down Expand Up @@ -1480,6 +1480,7 @@ mod tests {
fields.insert("http_status_code".to_string(), int_value(200));
fields.insert("headers".to_string(), empty_struct_value());
fields.insert("payload".to_string(), string_value("20"));
fields.insert("http_schema".to_string(), string_value("text/plain"));
Value {
kind: Some(Kind::StructValue(Struct { fields })),
}
Expand Down Expand Up @@ -1581,9 +1582,9 @@ mod tests {
"rest::control::respond",
vec![
literal_param(100, "http_status_code", int_value(200)),
literal_param(101, "headers", empty_struct_value()),
literal_param(102, "http_schema", string_value("application/json")),
literal_param(103, "payload", string_value("hello")),
literal_param(101, "headers", empty_struct_value()),
],
Some(2),
);
Expand Down
11 changes: 9 additions & 2 deletions crates/taurus-core/src/runtime/functions/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,24 @@ fn respond(
_ctx: &mut ValueStore,
_run: &mut crate::handler::registry::ThunkRunner<'_>,
) -> Signal {
args!(args => http_status_code: i64, headers: Struct, _http_schema: String, payload: Value);
args!(args => http_status_code: i64, http_schema: String, payload: Value, headers: Value);

let http_headers = match headers_from_value(&headers) {
Ok(headers) => headers,
Err(signal) => return signal,
};

let mut fields = HashMap::new();
fields.insert("http_status_code".to_string(), http_status_code.to_value());
fields.insert(
"headers".to_string(),
Value {
kind: Some(Kind::StructValue(headers)),
kind: Some(Kind::StructValue(http_headers)),
},
);

fields.insert("payload".to_string(), payload);
fields.insert("http_schema".to_string(), http_schema.to_value());

// `Respond` is a control signal; the executor can still continue with `next` if present.
Signal::Respond(Value {
Expand Down
7 changes: 2 additions & 5 deletions crates/taurus/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ pub async fn run() {
let client = connect_nats(&config).await;

let mut health_task = spawn_health_task(&config);
let (
runtime_status_service,
runtime_execution_service,
mut runtime_status_heartbeat_task,
) = setup_dynamic_services_if_needed(&config).await;
let (runtime_status_service, runtime_execution_service, mut runtime_status_heartbeat_task) =
setup_dynamic_services_if_needed(&config).await;

let nats_remote = NATSRemoteRuntime::new(client.clone());
let runtime_emitter = NATSRespondEmitter::new(client.clone());
Expand Down
2 changes: 1 addition & 1 deletion crates/taurus/src/app/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ async fn execute_flow(
input,
signal: report.signal,
node_execution_results: report.node_execution_results,
}
}
}

fn parse_execution_id_from_subject(
Expand Down
33 changes: 17 additions & 16 deletions flows/01_return_object.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"headers": {
"Header": "X"
},
"payload": "Hello World"
"payload": "Hello World",
"http_schema": "application/json"
}
}
],
Expand All @@ -32,21 +33,6 @@
}
}
},
{
"databaseId": "2",
"runtimeParameterId": "headers",
"value": {
"literalValue": {
"structValue": {
"fields": {
"Header": {
"stringValue": "X"
}
}
}
}
}
},
{
"databaseId": "4",
"runtimeParameterId": "http_schema",
Expand All @@ -64,6 +50,21 @@
"stringValue": "Hello World"
}
}
},
{
"databaseId": "2",
"runtimeParameterId": "headers",
"value": {
"literalValue": {
"structValue": {
"fields": {
"Header": {
"stringValue": "X"
}
}
}
}
}
}
]
}
Expand Down
36 changes: 19 additions & 17 deletions flows/02_return_flow_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"headers": {
"Authentication": "X"
},
"payload": null
"payload": null,
"http_schema": "application/json"
}
},
{
Expand All @@ -35,7 +36,8 @@
"cat",
"bird"
]
}
},
"http_schema": "application/json"
}
}
],
Expand All @@ -60,21 +62,6 @@
}
}
},
{
"databaseId": "6",
"runtimeParameterId": "headers",
"value": {
"literalValue": {
"structValue": {
"fields": {
"Authentication": {
"stringValue": "X"
}
}
}
}
}
},
{
"databaseId": "8",
"runtimeParameterId": "http_schema",
Expand All @@ -92,6 +79,21 @@
"flowInput": {}
}
}
},
{
"databaseId": "6",
"runtimeParameterId": "headers",
"value": {
"literalValue": {
"structValue": {
"fields": {
"Authentication": {
"stringValue": "X"
}
}
}
}
}
}
]
}
Expand Down
42 changes: 22 additions & 20 deletions flows/05_if_control.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"expected_result": {
"http_status_code": 200,
"headers": {},
"payload": "Blub"
"payload": "Blub",
"http_schema": "application/json"
}
},
{
Expand All @@ -46,7 +47,8 @@
"expected_result": {
"http_status_code": 200,
"headers": {},
"payload": "Blub"
"payload": "Blub",
"http_schema": "application/json"
}
}
],
Expand Down Expand Up @@ -87,15 +89,6 @@
}
}
},
{
"databaseId": "55",
"runtimeParameterId": "headers",
"value": {
"literalValue": {
"structValue": {}
}
}
},
{
"databaseId": "57",
"runtimeParameterId": "http_schema",
Expand All @@ -113,6 +106,15 @@
"stringValue": "Blub"
}
}
},
{
"databaseId": "55",
"runtimeParameterId": "headers",
"value": {
"literalValue": {
"structValue": {}
}
}
}
]
},
Expand Down Expand Up @@ -166,15 +168,6 @@
}
}
},
{
"databaseId": "52",
"runtimeParameterId": "headers",
"value": {
"literalValue": {
"structValue": {}
}
}
},
{
"databaseId": "54",
"runtimeParameterId": "http_schema",
Expand All @@ -200,6 +193,15 @@
"flowInput": {}
}
}
},
{
"databaseId": "52",
"runtimeParameterId": "headers",
"value": {
"literalValue": {
"structValue": {}
}
}
}
]
}
Expand Down
42 changes: 22 additions & 20 deletions flows/06_if_else_control.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"expected_result": {
"http_status_code": 200,
"headers": {},
"payload": "Blub"
"payload": "Blub",
"http_schema": "application/json"
}
},
{
Expand All @@ -46,7 +47,8 @@
"expected_result": {
"http_status_code": 200,
"headers": {},
"payload": "Blob"
"payload": "Blob",
"http_schema": "application/json"
}
}
],
Expand Down Expand Up @@ -87,15 +89,6 @@
}
}
},
{
"databaseId": "78",
"runtimeParameterId": "headers",
"value": {
"literalValue": {
"structValue": {}
}
}
},
{
"databaseId": "80",
"runtimeParameterId": "http_schema",
Expand All @@ -113,6 +106,15 @@
"stringValue": "Blub"
}
}
},
{
"databaseId": "78",
"runtimeParameterId": "headers",
"value": {
"literalValue": {
"structValue": {}
}
}
}
]
},
Expand Down Expand Up @@ -176,15 +178,6 @@
}
}
},
{
"databaseId": "73",
"runtimeParameterId": "headers",
"value": {
"literalValue": {
"structValue": {}
}
}
},
{
"databaseId": "76",
"runtimeParameterId": "http_schema",
Expand All @@ -202,6 +195,15 @@
"stringValue": "Blob"
}
}
},
{
"databaseId": "73",
"runtimeParameterId": "headers",
"value": {
"literalValue": {
"structValue": {}
}
}
}
]
}
Expand Down
Loading