From aeb6df36ec3b7591543e35137f008374849d0477 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 22 Aug 2024 17:13:01 +0200 Subject: [PATCH 01/19] feat: added external proto to build/lib configuration --- build/rust/build.rs | 44 +++++++++++++++++++++++++++++++------------ build/rust/src/lib.rs | 4 ++++ 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/build/rust/build.rs b/build/rust/build.rs index 0316276..e6481b8 100644 --- a/build/rust/build.rs +++ b/build/rust/build.rs @@ -3,14 +3,33 @@ use std::io::Result; fn main() -> Result<()> { - let path = "src/internal"; + let internal_path = "src/internal"; + let external_path = "src/internal"; - if !std::path::Path::new(&path).exists() { - create_dir(path)?; + let internal_proto = &[ + "variable.proto", + "rule.proto", + "type.proto", + "node.proto", + "flow.proto", + ]; + + let external_proto = &[ + "definitions.proto", + "action.proto", + "transfer.proto" + ]; + + if !std::path::Path::new(&internal_path).exists() { + create_dir(internal_path)?; + } + + if !std::path::Path::new(&external_path).exists() { + create_dir(external_path)?; } tonic_build::configure() - .out_dir(path) + .out_dir(internal_path) .build_server(true) .build_client(true) .type_attribute("Variable", "#[derive(serde::Serialize, serde::Deserialize)]") @@ -20,14 +39,15 @@ fn main() -> Result<()> { .type_attribute("Parameter", "#[derive(serde::Serialize, serde::Deserialize)]") .type_attribute("Node", "#[derive(serde::Serialize, serde::Deserialize)]") .type_attribute("Flow", "#[derive(serde::Serialize, serde::Deserialize)]") - .compile(&[ - "variable.proto", - "rule.proto", - "type.proto", - "node.proto", - "flow.proto", - ], &["../../internal"]) - .expect("Cannot compile protos"); + .compile(internal_proto, &["../../internal"]) + .expect("Cannot compile internal protos"); + + tonic_build::configure() + .out_dir(external_path) + .build_server(true) + .build_client(true) + .compile(external_proto, &["../../external"]) + .expect("Cannot compile external protos"); Ok(()) } \ No newline at end of file diff --git a/build/rust/src/lib.rs b/build/rust/src/lib.rs index 0e01a6e..0100d39 100644 --- a/build/rust/src/lib.rs +++ b/build/rust/src/lib.rs @@ -1,3 +1,7 @@ pub mod internal { include!("internal/internal.rs"); +} + +pub mod external { + include!("external/external.rs"); } \ No newline at end of file From 60d529ad5ffc9afc42a1dc22aa81e639c1d751c1 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 22 Aug 2024 17:13:13 +0200 Subject: [PATCH 02/19] feat: added external proto files --- external/action.proto | 34 ++++++++++++++++++++++++++++++++++ external/definitions.proto | 34 ++++++++++++++++++++++++++++++++++ external/transfer.proto | 21 +++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 external/action.proto create mode 100644 external/definitions.proto create mode 100644 external/transfer.proto diff --git a/external/action.proto b/external/action.proto new file mode 100644 index 0000000..6393650 --- /dev/null +++ b/external/action.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; +import "definitions.proto"; + +package external; + +message ActionLogonRequest { + string identifier = 1; +} + +message ActionLogonResponse {} + +message ActionLogoffRequest { + string identifier = 1; +} + +message ActionLogoffResponse {} + +message ActionTransferRequest { + repeated Runtime2RuntimeFunctionDefinition runtime2runtimeFunctionDefinition = 1; + repeated RuntimeFunctionDefinition runtimeFunctionDefinition = 2; + repeated RuntimeParameterDefinition runtimeParameterDefinition = 3; + repeated FunctionDefinition functionDefinition = 4; + repeated ParameterDefinition parameterDefinition = 5; +} + +message ActionTransferResponse { + bool success = 1; +} + +service ActionService { + rpc Logon (ActionLogonRequest) returns (ActionLogonResponse); + rpc Logoff (ActionLogoffRequest) returns (ActionLogoffResponse); + rpc Transfer (ActionTransferRequest) returns (ActionTransferResponse); +} \ No newline at end of file diff --git a/external/definitions.proto b/external/definitions.proto new file mode 100644 index 0000000..664fae6 --- /dev/null +++ b/external/definitions.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; + +package external; + +message Runtime2RuntimeFunctionDefinition { + int32 id = 1; + int32 runtime_id = 2; + int32 runtime_function_id = 3; +} + +message RuntimeFunctionDefinition { + int32 id = 1; + int32 return_type = 2; +} + +message RuntimeParameterDefinition { + int32 id = 1; + int32 runtime_function_id = 2; + int32 type = 3; + string name = 4; +} + +message FunctionDefinition { + int32 id = 1; + int32 runtime_function_id = 2; + int32 return_type = 3; +} + +message ParameterDefinition { + int32 id = 1; + int32 function_id = 2; + int32 type = 3; + string name = 4; +} \ No newline at end of file diff --git a/external/transfer.proto b/external/transfer.proto new file mode 100644 index 0000000..8c91650 --- /dev/null +++ b/external/transfer.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +import "definitions.proto"; + +package external; + +message Information { + string identifier = 1; + + oneof message_type { + Runtime2RuntimeFunctionDefinition runtime2RuntimeFunctionDefinition = 2; + RuntimeFunctionDefinition runtimeFunctionDefinition = 3; + RuntimeParameterDefinition runtimeParameterDefinition = 4; + FunctionDefinition functionDefinition = 5; + ParameterDefinition parameterDefinition = 6; + } +} + +service ActionTransferService { + rpc TransferInformation(stream Information) returns (stream Information); +} \ No newline at end of file From a7b81ba00dee14c041c8c06f65153875214fd40f Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 22 Aug 2024 17:13:13 +0200 Subject: [PATCH 03/19] feat: added external proto files --- build/rust/build.rs | 2 +- external/action.proto | 34 ++++++++++++++++++++++++++++++++++ external/definitions.proto | 34 ++++++++++++++++++++++++++++++++++ external/transfer.proto | 21 +++++++++++++++++++++ 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 external/action.proto create mode 100644 external/definitions.proto create mode 100644 external/transfer.proto diff --git a/build/rust/build.rs b/build/rust/build.rs index e6481b8..41e678d 100644 --- a/build/rust/build.rs +++ b/build/rust/build.rs @@ -4,7 +4,7 @@ use std::io::Result; fn main() -> Result<()> { let internal_path = "src/internal"; - let external_path = "src/internal"; + let external_path = "src/external"; let internal_proto = &[ "variable.proto", diff --git a/external/action.proto b/external/action.proto new file mode 100644 index 0000000..6393650 --- /dev/null +++ b/external/action.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; +import "definitions.proto"; + +package external; + +message ActionLogonRequest { + string identifier = 1; +} + +message ActionLogonResponse {} + +message ActionLogoffRequest { + string identifier = 1; +} + +message ActionLogoffResponse {} + +message ActionTransferRequest { + repeated Runtime2RuntimeFunctionDefinition runtime2runtimeFunctionDefinition = 1; + repeated RuntimeFunctionDefinition runtimeFunctionDefinition = 2; + repeated RuntimeParameterDefinition runtimeParameterDefinition = 3; + repeated FunctionDefinition functionDefinition = 4; + repeated ParameterDefinition parameterDefinition = 5; +} + +message ActionTransferResponse { + bool success = 1; +} + +service ActionService { + rpc Logon (ActionLogonRequest) returns (ActionLogonResponse); + rpc Logoff (ActionLogoffRequest) returns (ActionLogoffResponse); + rpc Transfer (ActionTransferRequest) returns (ActionTransferResponse); +} \ No newline at end of file diff --git a/external/definitions.proto b/external/definitions.proto new file mode 100644 index 0000000..664fae6 --- /dev/null +++ b/external/definitions.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; + +package external; + +message Runtime2RuntimeFunctionDefinition { + int32 id = 1; + int32 runtime_id = 2; + int32 runtime_function_id = 3; +} + +message RuntimeFunctionDefinition { + int32 id = 1; + int32 return_type = 2; +} + +message RuntimeParameterDefinition { + int32 id = 1; + int32 runtime_function_id = 2; + int32 type = 3; + string name = 4; +} + +message FunctionDefinition { + int32 id = 1; + int32 runtime_function_id = 2; + int32 return_type = 3; +} + +message ParameterDefinition { + int32 id = 1; + int32 function_id = 2; + int32 type = 3; + string name = 4; +} \ No newline at end of file diff --git a/external/transfer.proto b/external/transfer.proto new file mode 100644 index 0000000..8c91650 --- /dev/null +++ b/external/transfer.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +import "definitions.proto"; + +package external; + +message Information { + string identifier = 1; + + oneof message_type { + Runtime2RuntimeFunctionDefinition runtime2RuntimeFunctionDefinition = 2; + RuntimeFunctionDefinition runtimeFunctionDefinition = 3; + RuntimeParameterDefinition runtimeParameterDefinition = 4; + FunctionDefinition functionDefinition = 5; + ParameterDefinition parameterDefinition = 6; + } +} + +service ActionTransferService { + rpc TransferInformation(stream Information) returns (stream Information); +} \ No newline at end of file From cfd3d61e1fc285f1f2c3f25112af674185b8a86f Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 22 Aug 2024 17:50:44 +0200 Subject: [PATCH 04/19] feat: added DataType & removed unneeded types --- external/action.proto | 7 ++----- external/definitions.proto | 22 +++++++++------------- external/transfer.proto | 16 +++++++--------- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/external/action.proto b/external/action.proto index 6393650..0549402 100644 --- a/external/action.proto +++ b/external/action.proto @@ -16,11 +16,8 @@ message ActionLogoffRequest { message ActionLogoffResponse {} message ActionTransferRequest { - repeated Runtime2RuntimeFunctionDefinition runtime2runtimeFunctionDefinition = 1; - repeated RuntimeFunctionDefinition runtimeFunctionDefinition = 2; - repeated RuntimeParameterDefinition runtimeParameterDefinition = 3; - repeated FunctionDefinition functionDefinition = 4; - repeated ParameterDefinition parameterDefinition = 5; + repeated RuntimeFunctionDefinition function_definition = 2; + repeated RuntimeParameterDefinition parameter_definition = 3; } message ActionTransferResponse { diff --git a/external/definitions.proto b/external/definitions.proto index 664fae6..bb1e1ba 100644 --- a/external/definitions.proto +++ b/external/definitions.proto @@ -2,12 +2,6 @@ syntax = "proto3"; package external; -message Runtime2RuntimeFunctionDefinition { - int32 id = 1; - int32 runtime_id = 2; - int32 runtime_function_id = 3; -} - message RuntimeFunctionDefinition { int32 id = 1; int32 return_type = 2; @@ -20,15 +14,17 @@ message RuntimeParameterDefinition { string name = 4; } -message FunctionDefinition { +message DataType { int32 id = 1; - int32 runtime_function_id = 2; + EDataType type = 2; int32 return_type = 3; + int32 parent = 4; } -message ParameterDefinition { - int32 id = 1; - int32 function_id = 2; - int32 type = 3; - string name = 4; +enum EDataType { + PRIMITIVE = 0; + TYPE = 1; + OBJECT = 2; + DATATYPE = 3; + FUNCTION = 4; } \ No newline at end of file diff --git a/external/transfer.proto b/external/transfer.proto index 8c91650..941d5bd 100644 --- a/external/transfer.proto +++ b/external/transfer.proto @@ -4,18 +4,16 @@ import "definitions.proto"; package external; -message Information { +message InformationRequest { string identifier = 1; + repeated RuntimeFunctionDefinition function_definition = 2; + repeated RuntimeParameterDefinition parameter_definition = 3; +} - oneof message_type { - Runtime2RuntimeFunctionDefinition runtime2RuntimeFunctionDefinition = 2; - RuntimeFunctionDefinition runtimeFunctionDefinition = 3; - RuntimeParameterDefinition runtimeParameterDefinition = 4; - FunctionDefinition functionDefinition = 5; - ParameterDefinition parameterDefinition = 6; - } +message InformationResponse { + bool success = 1; } service ActionTransferService { - rpc TransferInformation(stream Information) returns (stream Information); + rpc Transfer (stream InformationRequest) returns (InformationRequest); } \ No newline at end of file From fa0eff59244b2deb35122886c218f6f097816d35 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 22 Aug 2024 20:49:37 +0200 Subject: [PATCH 05/19] feat: added identifier field for action transfer request --- external/action.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/external/action.proto b/external/action.proto index 0549402..70a9e4e 100644 --- a/external/action.proto +++ b/external/action.proto @@ -16,6 +16,7 @@ message ActionLogoffRequest { message ActionLogoffResponse {} message ActionTransferRequest { + string identifier = 1; repeated RuntimeFunctionDefinition function_definition = 2; repeated RuntimeParameterDefinition parameter_definition = 3; } From 58b3dbd462fbe4399787bcb867b8ddac84377d8c Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 23 Aug 2024 08:41:44 +0200 Subject: [PATCH 06/19] ref: moved definitions.proto into shared folder --- external/transfer.proto | 4 ++-- {external => internal}/action.proto | 4 +++- {external => shared}/definitions.proto | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) rename {external => internal}/action.proto (81%) rename {external => shared}/definitions.proto (95%) diff --git a/external/transfer.proto b/external/transfer.proto index 941d5bd..ba0967b 100644 --- a/external/transfer.proto +++ b/external/transfer.proto @@ -6,8 +6,8 @@ package external; message InformationRequest { string identifier = 1; - repeated RuntimeFunctionDefinition function_definition = 2; - repeated RuntimeParameterDefinition parameter_definition = 3; + repeated shared.RuntimeFunctionDefinition function_definition = 2; + repeated shared.RuntimeParameterDefinition parameter_definition = 3; } message InformationResponse { diff --git a/external/action.proto b/internal/action.proto similarity index 81% rename from external/action.proto rename to internal/action.proto index 70a9e4e..e4bf14b 100644 --- a/external/action.proto +++ b/internal/action.proto @@ -1,10 +1,12 @@ syntax = "proto3"; import "definitions.proto"; -package external; +package internal; message ActionLogonRequest { string identifier = 1; + repeated shared.RuntimeFunctionDefinition function_definition = 2; + repeated shared.RuntimeParameterDefinition parameter_definition = 3; } message ActionLogonResponse {} diff --git a/external/definitions.proto b/shared/definitions.proto similarity index 95% rename from external/definitions.proto rename to shared/definitions.proto index bb1e1ba..2d83e94 100644 --- a/external/definitions.proto +++ b/shared/definitions.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package external; +package shared; message RuntimeFunctionDefinition { int32 id = 1; From b041e2fa1b80d8892033c6df03c0374ac0690f67 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 23 Aug 2024 08:41:55 +0200 Subject: [PATCH 07/19] feat: adjusted build configuration --- build/rust/build.rs | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/build/rust/build.rs b/build/rust/build.rs index 41e678d..739dcfb 100644 --- a/build/rust/build.rs +++ b/build/rust/build.rs @@ -3,33 +3,31 @@ use std::io::Result; fn main() -> Result<()> { - let internal_path = "src/internal"; - let external_path = "src/external"; - - let internal_proto = &[ + let proto = &[ + "definitions.proto", "variable.proto", "rule.proto", "type.proto", "node.proto", "flow.proto", - ]; - - let external_proto = &[ - "definitions.proto", "action.proto", "transfer.proto" ]; - if !std::path::Path::new(&internal_path).exists() { - create_dir(internal_path)?; - } + let inclusions = &[ + "../../shared", + "../../internal", + "../../external", + ]; + + let out_path = "src/generated"; - if !std::path::Path::new(&external_path).exists() { - create_dir(external_path)?; + if !std::path::Path::new(&out_path).exists() { + create_dir(out_path)?; } tonic_build::configure() - .out_dir(internal_path) + .out_dir(out_path) .build_server(true) .build_client(true) .type_attribute("Variable", "#[derive(serde::Serialize, serde::Deserialize)]") @@ -39,15 +37,8 @@ fn main() -> Result<()> { .type_attribute("Parameter", "#[derive(serde::Serialize, serde::Deserialize)]") .type_attribute("Node", "#[derive(serde::Serialize, serde::Deserialize)]") .type_attribute("Flow", "#[derive(serde::Serialize, serde::Deserialize)]") - .compile(internal_proto, &["../../internal"]) + .compile(proto, inclusions) .expect("Cannot compile internal protos"); - tonic_build::configure() - .out_dir(external_path) - .build_server(true) - .build_client(true) - .compile(external_proto, &["../../external"]) - .expect("Cannot compile external protos"); - Ok(()) } \ No newline at end of file From 622b0ae3df190e22a74308e6a7ba4cd045135654 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 23 Aug 2024 08:42:15 +0200 Subject: [PATCH 08/19] feat: flows are now updated via stream --- internal/flow.proto | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/internal/flow.proto b/internal/flow.proto index 5695c76..9b0b4fb 100644 --- a/internal/flow.proto +++ b/internal/flow.proto @@ -16,23 +16,19 @@ message Flow { int64 last_updated = 5; } -//Sagittarius sends flow to be updated -message FlowUpdateRequest { - Flow updated_flow = 1; -} - -//Aquila response with success or retry of update -message FlowUpdateResponse { - bool success = 1; +enum FlowCommandType { + INSERT = 0; + DELETE = 1; } -//Sagittarius sends flow_id to be updated -message FlowDeleteRequest { - int64 flow_id = 1; +//Sagittarius sends flow to be updated +message FlowRequest { + Flow updated_flow = 1; + FlowCommandType type = 2; } -//Aquila response with success or retry of deletion -message FlowDeleteResponse { +//Aquila response with success or failure +message FlowResponse { bool success = 1; } @@ -50,8 +46,7 @@ message FlowGetResponse { } service FlowAquilaService { - rpc Update (FlowUpdateRequest) returns (FlowUpdateResponse) {} - rpc Delete (FlowDeleteRequest) returns (FlowDeleteResponse) {} + rpc Update (stream FlowRequest) returns (stream FlowResponse) {} } service FlowSagittariusService { From 42f0a388aa09aeb48b873a7117629c8fbf49236e Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 23 Aug 2024 08:42:24 +0200 Subject: [PATCH 09/19] feat: added shared module --- build/rust/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build/rust/src/lib.rs b/build/rust/src/lib.rs index 0100d39..99e15e4 100644 --- a/build/rust/src/lib.rs +++ b/build/rust/src/lib.rs @@ -1,7 +1,11 @@ pub mod internal { - include!("internal/internal.rs"); + include!("generated/internal.rs"); } pub mod external { - include!("external/external.rs"); + include!("generated/external.rs"); +} + +pub mod shared { + include!("generated/shared.rs"); } \ No newline at end of file From f6597b3fd0723d63fa0762506b55b15bdaf52fe2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 23 Aug 2024 08:42:41 +0200 Subject: [PATCH 10/19] fix: removed unneeded message type --- internal/action.proto | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/internal/action.proto b/internal/action.proto index e4bf14b..7d5fb00 100644 --- a/internal/action.proto +++ b/internal/action.proto @@ -17,18 +17,7 @@ message ActionLogoffRequest { message ActionLogoffResponse {} -message ActionTransferRequest { - string identifier = 1; - repeated RuntimeFunctionDefinition function_definition = 2; - repeated RuntimeParameterDefinition parameter_definition = 3; -} - -message ActionTransferResponse { - bool success = 1; -} - service ActionService { rpc Logon (ActionLogonRequest) returns (ActionLogonResponse); rpc Logoff (ActionLogoffRequest) returns (ActionLogoffResponse); - rpc Transfer (ActionTransferRequest) returns (ActionTransferResponse); } \ No newline at end of file From 7404d29563b9994535392538639342f4e1e43779 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 23 Aug 2024 21:21:07 +0200 Subject: [PATCH 11/19] feat: started to adjust flows to new database schema --- build/rust/build.rs | 20 ++++++++++++-------- internal/flow.proto | 7 ++----- internal/flow_definition.proto | 9 +++++++++ internal/flow_type.proto | 13 +++++++++++++ internal/function_definition.proto | 14 ++++++++++++++ internal/node.proto | 20 +++++++++----------- internal/parameter_definition.proto | 15 +++++++++++++++ internal/runtime_function_definition.proto | 12 ++++++++++++ internal/type.proto | 15 --------------- 9 files changed, 86 insertions(+), 39 deletions(-) create mode 100644 internal/flow_definition.proto create mode 100644 internal/flow_type.proto create mode 100644 internal/function_definition.proto create mode 100644 internal/parameter_definition.proto create mode 100644 internal/runtime_function_definition.proto delete mode 100644 internal/type.proto diff --git a/build/rust/build.rs b/build/rust/build.rs index 739dcfb..9e82755 100644 --- a/build/rust/build.rs +++ b/build/rust/build.rs @@ -5,13 +5,16 @@ fn main() -> Result<()> { let proto = &[ "definitions.proto", - "variable.proto", - "rule.proto", - "type.proto", + "flow_definition.proto", + "flow_type.proto", + "function_definition.proto", + "ping.proto", + "runtime_function_definition.proto", "node.proto", "flow.proto", "action.proto", - "transfer.proto" + "transfer.proto", + "ping.proto" ]; let inclusions = &[ @@ -31,12 +34,13 @@ fn main() -> Result<()> { .build_server(true) .build_client(true) .type_attribute("Variable", "#[derive(serde::Serialize, serde::Deserialize)]") - .type_attribute("RuleType", "#[derive(serde::Serialize, serde::Deserialize)]") - .type_attribute("Rule", "#[derive(serde::Serialize, serde::Deserialize)]") - .type_attribute("Type", "#[derive(serde::Serialize, serde::Deserialize)]") - .type_attribute("Parameter", "#[derive(serde::Serialize, serde::Deserialize)]") + .type_attribute("FlowDefinition", "#[derive(serde::Serialize, serde::Deserialize)]") + .type_attribute("FlowType", "#[derive(serde::Serialize, serde::Deserialize)]") + .type_attribute("FunctionDefinition", "#[derive(serde::Serialize, serde::Deserialize)]") + .type_attribute("RuntimeFunctionDefinition", "#[derive(serde::Serialize, serde::Deserialize)]") .type_attribute("Node", "#[derive(serde::Serialize, serde::Deserialize)]") .type_attribute("Flow", "#[derive(serde::Serialize, serde::Deserialize)]") + .type_attribute("DataType", "#[derive(serde::Serialize, serde::Deserialize)]") .compile(proto, inclusions) .expect("Cannot compile internal protos"); diff --git a/internal/flow.proto b/internal/flow.proto index 9b0b4fb..5d306c8 100644 --- a/internal/flow.proto +++ b/internal/flow.proto @@ -5,15 +5,12 @@ option ruby_package = "Tucana::Internal"; package internal; import "node.proto"; -import "type.proto"; -import "variable.proto"; +import "flow_type.proto"; message Flow { int64 flow_id = 1; Node starting_node = 2; - repeated Type types = 3; - repeated Variable context = 4; - int64 last_updated = 5; + FlowType type = 3; } enum FlowCommandType { diff --git a/internal/flow_definition.proto b/internal/flow_definition.proto new file mode 100644 index 0000000..8f2f9fb --- /dev/null +++ b/internal/flow_definition.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +option ruby_package = "Tucana::Internal"; + +package internal; + +message FlowDefinition { + int32 id = 1; +} \ No newline at end of file diff --git a/internal/flow_type.proto b/internal/flow_type.proto new file mode 100644 index 0000000..e9a4642 --- /dev/null +++ b/internal/flow_type.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +option ruby_package = "Tucana::Internal"; + +package internal; + +import "flow_definition.proto"; + +message FlowType { + int32 id = 1; + string name = 2; + FlowDefinition flow_definition = 3; +} \ No newline at end of file diff --git a/internal/function_definition.proto b/internal/function_definition.proto new file mode 100644 index 0000000..bf61447 --- /dev/null +++ b/internal/function_definition.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +option ruby_package = "Tucana::Internal"; + +import "definitions.proto"; +import "runtime_function_definition.proto"; + +package internal; + +message FunctionDefinition { + int32 id = 1; + RuntimeFunctionDefinition runtime_function_definition = 2; + shared.DataType return_type = 3; +} \ No newline at end of file diff --git a/internal/node.proto b/internal/node.proto index 79c7942..37ae5a3 100644 --- a/internal/node.proto +++ b/internal/node.proto @@ -4,21 +4,19 @@ option ruby_package = "Tucana::Internal"; package internal; -import "variable.proto"; +import "function_definition.proto"; +import "parameter_definition.proto"; message Node { int64 node_id = 1; - repeated Parameter parameter = 2; - optional string return_type = 3; - optional Node next_node = 4; - repeated Variable context = 5; + FunctionDefinition function_definition = 2; + optional Node next_node = 3; } message Parameter { - int64 parameter_id = 1; - string name = 2; - string type = 3; - optional string value = 4; + int64 id = 1; + Node parent = 2; + ParameterDefinition parameter_definition = 3; + string name = 4; optional Node sub_node = 5; - optional int32 type_ref = 6; -} +} \ No newline at end of file diff --git a/internal/parameter_definition.proto b/internal/parameter_definition.proto new file mode 100644 index 0000000..1da3abb --- /dev/null +++ b/internal/parameter_definition.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +import "function_definition.proto"; + +option ruby_package = "Tucana::Internal"; + +package internal; + +import "definitions.proto"; + +message ParameterDefinition { + int32 id = 1; + FunctionDefinition function_definition = 2; + shared.DataType type = 3; + string name = 4; +} \ No newline at end of file diff --git a/internal/runtime_function_definition.proto b/internal/runtime_function_definition.proto new file mode 100644 index 0000000..7fe851d --- /dev/null +++ b/internal/runtime_function_definition.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +option ruby_package = "Tucana::Internal"; + +import "definitions.proto"; + +package internal; + +message RuntimeFunctionDefinition { + int32 id = 1; + shared.DataType return_type = 2; +} \ No newline at end of file diff --git a/internal/type.proto b/internal/type.proto deleted file mode 100644 index 50e640a..0000000 --- a/internal/type.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto3"; - -option ruby_package = "Tucana::Internal"; - -package internal; - -import "rule.proto"; - -message Type { - string name = 1; - string type = 2; - optional bool array = 3; - repeated Rule rules = 4; - optional Type parent = 5; -} \ No newline at end of file From d01ac7d0e85a687cf6a3b42660d3bf6707326f64 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 23 Aug 2024 21:21:29 +0200 Subject: [PATCH 12/19] fix: InformationRequest now returns InformationResponse --- external/transfer.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/transfer.proto b/external/transfer.proto index ba0967b..cea81bc 100644 --- a/external/transfer.proto +++ b/external/transfer.proto @@ -15,5 +15,5 @@ message InformationResponse { } service ActionTransferService { - rpc Transfer (stream InformationRequest) returns (InformationRequest); + rpc Transfer (stream InformationRequest) returns (InformationResponse); } \ No newline at end of file From d1b6817a304f6b431106e0e0d0afe2006b8997c7 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 27 Aug 2024 16:32:53 +0200 Subject: [PATCH 13/19] feat: adjusted building configuration to current proto files --- build/rust/build.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/build/rust/build.rs b/build/rust/build.rs index 9e82755..b9d60bb 100644 --- a/build/rust/build.rs +++ b/build/rust/build.rs @@ -6,10 +6,8 @@ fn main() -> Result<()> { let proto = &[ "definitions.proto", "flow_definition.proto", - "flow_type.proto", - "function_definition.proto", - "ping.proto", "runtime_function_definition.proto", + "runtime_parameter_definition.proto", "node.proto", "flow.proto", "action.proto", @@ -33,14 +31,12 @@ fn main() -> Result<()> { .out_dir(out_path) .build_server(true) .build_client(true) - .type_attribute("Variable", "#[derive(serde::Serialize, serde::Deserialize)]") .type_attribute("FlowDefinition", "#[derive(serde::Serialize, serde::Deserialize)]") - .type_attribute("FlowType", "#[derive(serde::Serialize, serde::Deserialize)]") - .type_attribute("FunctionDefinition", "#[derive(serde::Serialize, serde::Deserialize)]") .type_attribute("RuntimeFunctionDefinition", "#[derive(serde::Serialize, serde::Deserialize)]") + .type_attribute("RuntimeParameterDefinition", "#[derive(serde::Serialize, serde::Deserialize)]") + .type_attribute("Parameter", "#[derive(serde::Serialize, serde::Deserialize)]") .type_attribute("Node", "#[derive(serde::Serialize, serde::Deserialize)]") .type_attribute("Flow", "#[derive(serde::Serialize, serde::Deserialize)]") - .type_attribute("DataType", "#[derive(serde::Serialize, serde::Deserialize)]") .compile(proto, inclusions) .expect("Cannot compile internal protos"); From 4d596503f9a1b67c9c7ca527a8b3ade1d84e92eb Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 27 Aug 2024 16:33:31 +0200 Subject: [PATCH 14/19] feat: updated proto files to latest communication-planing --- internal/flow.proto | 23 ++++++++----------- internal/flow_definition.proto | 1 - internal/flow_type.proto | 13 ----------- internal/function_definition.proto | 14 ----------- internal/node.proto | 18 +++++++-------- internal/parameter_definition.proto | 15 ------------ internal/rule.proto | 16 ------------- internal/runtime_function_definition.proto | 5 +--- ...oto => runtime_parameter_definition.proto} | 3 +-- 9 files changed, 19 insertions(+), 89 deletions(-) delete mode 100644 internal/flow_type.proto delete mode 100644 internal/function_definition.proto delete mode 100644 internal/parameter_definition.proto delete mode 100644 internal/rule.proto rename internal/{variable.proto => runtime_parameter_definition.proto} (72%) diff --git a/internal/flow.proto b/internal/flow.proto index 5d306c8..e5e0118 100644 --- a/internal/flow.proto +++ b/internal/flow.proto @@ -5,12 +5,11 @@ option ruby_package = "Tucana::Internal"; package internal; import "node.proto"; -import "flow_type.proto"; +import "flow_definition.proto"; message Flow { - int64 flow_id = 1; Node starting_node = 2; - FlowType type = 3; + FlowDefinition definition = 3; } enum FlowCommandType { @@ -18,15 +17,14 @@ enum FlowCommandType { DELETE = 1; } -//Sagittarius sends flow to be updated -message FlowRequest { - Flow updated_flow = 1; - FlowCommandType type = 2; +//Aquila sends a request to initialise stream to Sagittarius +message FlowLogonRequest { } -//Aquila response with success or failure +//Sagittarius sends flow to be updated message FlowResponse { - bool success = 1; + Flow updated_flow = 1; + FlowCommandType type = 2; } //All ids of flows that Aquila holds @@ -42,10 +40,7 @@ message FlowGetResponse { repeated int64 deleted_flow_ids = 2; } -service FlowAquilaService { - rpc Update (stream FlowRequest) returns (stream FlowResponse) {} -} - -service FlowSagittariusService { +service FlowService { rpc Get (FlowGetRequest) returns (FlowGetResponse) {} + rpc Update (FlowLogonRequest) returns (stream FlowResponse) {} } \ No newline at end of file diff --git a/internal/flow_definition.proto b/internal/flow_definition.proto index 8f2f9fb..a1af7fe 100644 --- a/internal/flow_definition.proto +++ b/internal/flow_definition.proto @@ -5,5 +5,4 @@ option ruby_package = "Tucana::Internal"; package internal; message FlowDefinition { - int32 id = 1; } \ No newline at end of file diff --git a/internal/flow_type.proto b/internal/flow_type.proto deleted file mode 100644 index e9a4642..0000000 --- a/internal/flow_type.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; - -option ruby_package = "Tucana::Internal"; - -package internal; - -import "flow_definition.proto"; - -message FlowType { - int32 id = 1; - string name = 2; - FlowDefinition flow_definition = 3; -} \ No newline at end of file diff --git a/internal/function_definition.proto b/internal/function_definition.proto deleted file mode 100644 index bf61447..0000000 --- a/internal/function_definition.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; - -option ruby_package = "Tucana::Internal"; - -import "definitions.proto"; -import "runtime_function_definition.proto"; - -package internal; - -message FunctionDefinition { - int32 id = 1; - RuntimeFunctionDefinition runtime_function_definition = 2; - shared.DataType return_type = 3; -} \ No newline at end of file diff --git a/internal/node.proto b/internal/node.proto index 37ae5a3..d51f46b 100644 --- a/internal/node.proto +++ b/internal/node.proto @@ -4,19 +4,17 @@ option ruby_package = "Tucana::Internal"; package internal; -import "function_definition.proto"; -import "parameter_definition.proto"; +import "runtime_function_definition.proto"; +import "runtime_parameter_definition.proto"; message Node { - int64 node_id = 1; - FunctionDefinition function_definition = 2; - optional Node next_node = 3; + RuntimeFunctionDefinition definition = 1; + optional Node next_node = 2; + repeated Parameter parameters = 3; } message Parameter { - int64 id = 1; - Node parent = 2; - ParameterDefinition parameter_definition = 3; - string name = 4; - optional Node sub_node = 5; + RuntimeParameterDefinition definition = 1; + optional string value = 2; + optional Node sub_node = 3; } \ No newline at end of file diff --git a/internal/parameter_definition.proto b/internal/parameter_definition.proto deleted file mode 100644 index 1da3abb..0000000 --- a/internal/parameter_definition.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto3"; -import "function_definition.proto"; - -option ruby_package = "Tucana::Internal"; - -package internal; - -import "definitions.proto"; - -message ParameterDefinition { - int32 id = 1; - FunctionDefinition function_definition = 2; - shared.DataType type = 3; - string name = 4; -} \ No newline at end of file diff --git a/internal/rule.proto b/internal/rule.proto deleted file mode 100644 index d7305d0..0000000 --- a/internal/rule.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; - -option ruby_package = "Tucana::Internal"; - -package internal; - -enum RuleType { - REGEX = 0; - NUMBER_RANGE = 1; - ITEM_OF_COLLECTION = 2; -} - -message Rule { - RuleType type = 1; - string config = 2; -} \ No newline at end of file diff --git a/internal/runtime_function_definition.proto b/internal/runtime_function_definition.proto index 7fe851d..148070e 100644 --- a/internal/runtime_function_definition.proto +++ b/internal/runtime_function_definition.proto @@ -2,11 +2,8 @@ syntax = "proto3"; option ruby_package = "Tucana::Internal"; -import "definitions.proto"; - package internal; message RuntimeFunctionDefinition { - int32 id = 1; - shared.DataType return_type = 2; + string id = 1; } \ No newline at end of file diff --git a/internal/variable.proto b/internal/runtime_parameter_definition.proto similarity index 72% rename from internal/variable.proto rename to internal/runtime_parameter_definition.proto index e2867f0..aad221d 100644 --- a/internal/variable.proto +++ b/internal/runtime_parameter_definition.proto @@ -4,7 +4,6 @@ option ruby_package = "Tucana::Internal"; package internal; -message Variable { +message RuntimeParameterDefinition { string name = 1; - string type = 2; } \ No newline at end of file From 003ef5d38d436bb10519811301e0a4a034cb25ca Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 27 Aug 2024 16:33:31 +0200 Subject: [PATCH 15/19] feat: updated proto files to latest communication-planing --- internal/flow.proto | 23 +++++++++------------- internal/flow_definition.proto | 1 - internal/flow_type.proto | 13 ------------ internal/function_definition.proto | 14 ------------- internal/node.proto | 17 +++++++--------- internal/parameter_definition.proto | 15 -------------- internal/rule.proto | 16 --------------- internal/runtime_function_definition.proto | 12 ----------- internal/variable.proto | 10 ---------- shared/definitions.proto | 23 ++-------------------- 10 files changed, 18 insertions(+), 126 deletions(-) delete mode 100644 internal/flow_type.proto delete mode 100644 internal/function_definition.proto delete mode 100644 internal/parameter_definition.proto delete mode 100644 internal/rule.proto delete mode 100644 internal/runtime_function_definition.proto delete mode 100644 internal/variable.proto diff --git a/internal/flow.proto b/internal/flow.proto index 5d306c8..e5e0118 100644 --- a/internal/flow.proto +++ b/internal/flow.proto @@ -5,12 +5,11 @@ option ruby_package = "Tucana::Internal"; package internal; import "node.proto"; -import "flow_type.proto"; +import "flow_definition.proto"; message Flow { - int64 flow_id = 1; Node starting_node = 2; - FlowType type = 3; + FlowDefinition definition = 3; } enum FlowCommandType { @@ -18,15 +17,14 @@ enum FlowCommandType { DELETE = 1; } -//Sagittarius sends flow to be updated -message FlowRequest { - Flow updated_flow = 1; - FlowCommandType type = 2; +//Aquila sends a request to initialise stream to Sagittarius +message FlowLogonRequest { } -//Aquila response with success or failure +//Sagittarius sends flow to be updated message FlowResponse { - bool success = 1; + Flow updated_flow = 1; + FlowCommandType type = 2; } //All ids of flows that Aquila holds @@ -42,10 +40,7 @@ message FlowGetResponse { repeated int64 deleted_flow_ids = 2; } -service FlowAquilaService { - rpc Update (stream FlowRequest) returns (stream FlowResponse) {} -} - -service FlowSagittariusService { +service FlowService { rpc Get (FlowGetRequest) returns (FlowGetResponse) {} + rpc Update (FlowLogonRequest) returns (stream FlowResponse) {} } \ No newline at end of file diff --git a/internal/flow_definition.proto b/internal/flow_definition.proto index 8f2f9fb..a1af7fe 100644 --- a/internal/flow_definition.proto +++ b/internal/flow_definition.proto @@ -5,5 +5,4 @@ option ruby_package = "Tucana::Internal"; package internal; message FlowDefinition { - int32 id = 1; } \ No newline at end of file diff --git a/internal/flow_type.proto b/internal/flow_type.proto deleted file mode 100644 index e9a4642..0000000 --- a/internal/flow_type.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; - -option ruby_package = "Tucana::Internal"; - -package internal; - -import "flow_definition.proto"; - -message FlowType { - int32 id = 1; - string name = 2; - FlowDefinition flow_definition = 3; -} \ No newline at end of file diff --git a/internal/function_definition.proto b/internal/function_definition.proto deleted file mode 100644 index bf61447..0000000 --- a/internal/function_definition.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; - -option ruby_package = "Tucana::Internal"; - -import "definitions.proto"; -import "runtime_function_definition.proto"; - -package internal; - -message FunctionDefinition { - int32 id = 1; - RuntimeFunctionDefinition runtime_function_definition = 2; - shared.DataType return_type = 3; -} \ No newline at end of file diff --git a/internal/node.proto b/internal/node.proto index 37ae5a3..13d8af9 100644 --- a/internal/node.proto +++ b/internal/node.proto @@ -4,19 +4,16 @@ option ruby_package = "Tucana::Internal"; package internal; -import "function_definition.proto"; -import "parameter_definition.proto"; +import "definitions.proto"; message Node { - int64 node_id = 1; - FunctionDefinition function_definition = 2; - optional Node next_node = 3; + shared.RuntimeFunctionDefinition definition = 1; + optional Node next_node = 2; + repeated Parameter parameters = 3; } message Parameter { - int64 id = 1; - Node parent = 2; - ParameterDefinition parameter_definition = 3; - string name = 4; - optional Node sub_node = 5; + shared.RuntimeParameterDefinition definition = 1; + optional string value = 2; + optional Node sub_node = 3; } \ No newline at end of file diff --git a/internal/parameter_definition.proto b/internal/parameter_definition.proto deleted file mode 100644 index 1da3abb..0000000 --- a/internal/parameter_definition.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto3"; -import "function_definition.proto"; - -option ruby_package = "Tucana::Internal"; - -package internal; - -import "definitions.proto"; - -message ParameterDefinition { - int32 id = 1; - FunctionDefinition function_definition = 2; - shared.DataType type = 3; - string name = 4; -} \ No newline at end of file diff --git a/internal/rule.proto b/internal/rule.proto deleted file mode 100644 index d7305d0..0000000 --- a/internal/rule.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; - -option ruby_package = "Tucana::Internal"; - -package internal; - -enum RuleType { - REGEX = 0; - NUMBER_RANGE = 1; - ITEM_OF_COLLECTION = 2; -} - -message Rule { - RuleType type = 1; - string config = 2; -} \ No newline at end of file diff --git a/internal/runtime_function_definition.proto b/internal/runtime_function_definition.proto deleted file mode 100644 index 7fe851d..0000000 --- a/internal/runtime_function_definition.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = "proto3"; - -option ruby_package = "Tucana::Internal"; - -import "definitions.proto"; - -package internal; - -message RuntimeFunctionDefinition { - int32 id = 1; - shared.DataType return_type = 2; -} \ No newline at end of file diff --git a/internal/variable.proto b/internal/variable.proto deleted file mode 100644 index e2867f0..0000000 --- a/internal/variable.proto +++ /dev/null @@ -1,10 +0,0 @@ -syntax = "proto3"; - -option ruby_package = "Tucana::Internal"; - -package internal; - -message Variable { - string name = 1; - string type = 2; -} \ No newline at end of file diff --git a/shared/definitions.proto b/shared/definitions.proto index 2d83e94..58028c2 100644 --- a/shared/definitions.proto +++ b/shared/definitions.proto @@ -3,28 +3,9 @@ syntax = "proto3"; package shared; message RuntimeFunctionDefinition { - int32 id = 1; - int32 return_type = 2; + string id = 1; } message RuntimeParameterDefinition { - int32 id = 1; - int32 runtime_function_id = 2; - int32 type = 3; - string name = 4; -} - -message DataType { - int32 id = 1; - EDataType type = 2; - int32 return_type = 3; - int32 parent = 4; -} - -enum EDataType { - PRIMITIVE = 0; - TYPE = 1; - OBJECT = 2; - DATATYPE = 3; - FUNCTION = 4; + string name = 1; } \ No newline at end of file From 7f0ba1b72ecb5704c36b2369723bc283486b766d Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 27 Aug 2024 17:34:03 +0200 Subject: [PATCH 16/19] fix: removed non-existing proto files for compiling --- build/rust/build.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/build/rust/build.rs b/build/rust/build.rs index b9d60bb..74bc80b 100644 --- a/build/rust/build.rs +++ b/build/rust/build.rs @@ -6,8 +6,6 @@ fn main() -> Result<()> { let proto = &[ "definitions.proto", "flow_definition.proto", - "runtime_function_definition.proto", - "runtime_parameter_definition.proto", "node.proto", "flow.proto", "action.proto", From d9a219fb3e9d1b67cd8802dca3c9fbfa48d7a1c2 Mon Sep 17 00:00:00 2001 From: Niklas van Schrick Date: Thu, 29 Aug 2024 20:33:41 +0200 Subject: [PATCH 17/19] Move proto files --- build/rust/build.rs | 6 +++--- build/rust/src/lib.rs | 4 ++-- {external => proto/actions}/transfer.proto | 4 +++- {internal => proto/internal}/action.proto | 2 ++ {internal => proto/internal}/flow.proto | 0 {internal => proto/internal}/flow_definition.proto | 0 {internal => proto/internal}/node.proto | 0 {internal => proto/internal}/ping.proto | 0 {shared => proto/shared}/definitions.proto | 2 ++ 9 files changed, 12 insertions(+), 6 deletions(-) rename {external => proto/actions}/transfer.proto (87%) rename {internal => proto/internal}/action.proto (92%) rename {internal => proto/internal}/flow.proto (100%) rename {internal => proto/internal}/flow_definition.proto (100%) rename {internal => proto/internal}/node.proto (100%) rename {internal => proto/internal}/ping.proto (100%) rename {shared => proto/shared}/definitions.proto (78%) diff --git a/build/rust/build.rs b/build/rust/build.rs index 74bc80b..c0eac72 100644 --- a/build/rust/build.rs +++ b/build/rust/build.rs @@ -14,9 +14,9 @@ fn main() -> Result<()> { ]; let inclusions = &[ - "../../shared", - "../../internal", - "../../external", + "../../proto/shared", + "../../proto/internal", + "../../proto/actions", ]; let out_path = "src/generated"; diff --git a/build/rust/src/lib.rs b/build/rust/src/lib.rs index 99e15e4..1a02dce 100644 --- a/build/rust/src/lib.rs +++ b/build/rust/src/lib.rs @@ -2,8 +2,8 @@ pub mod internal { include!("generated/internal.rs"); } -pub mod external { - include!("generated/external.rs"); +pub mod actions { + include!("generated/actions.rs"); } pub mod shared { diff --git a/external/transfer.proto b/proto/actions/transfer.proto similarity index 87% rename from external/transfer.proto rename to proto/actions/transfer.proto index cea81bc..5021338 100644 --- a/external/transfer.proto +++ b/proto/actions/transfer.proto @@ -2,7 +2,9 @@ syntax = "proto3"; import "definitions.proto"; -package external; +option ruby_package = "Tucana::Actions"; + +package actions; message InformationRequest { string identifier = 1; diff --git a/internal/action.proto b/proto/internal/action.proto similarity index 92% rename from internal/action.proto rename to proto/internal/action.proto index 7d5fb00..989b6a4 100644 --- a/internal/action.proto +++ b/proto/internal/action.proto @@ -1,6 +1,8 @@ syntax = "proto3"; import "definitions.proto"; +option ruby_package = "Tucana::Internal"; + package internal; message ActionLogonRequest { diff --git a/internal/flow.proto b/proto/internal/flow.proto similarity index 100% rename from internal/flow.proto rename to proto/internal/flow.proto diff --git a/internal/flow_definition.proto b/proto/internal/flow_definition.proto similarity index 100% rename from internal/flow_definition.proto rename to proto/internal/flow_definition.proto diff --git a/internal/node.proto b/proto/internal/node.proto similarity index 100% rename from internal/node.proto rename to proto/internal/node.proto diff --git a/internal/ping.proto b/proto/internal/ping.proto similarity index 100% rename from internal/ping.proto rename to proto/internal/ping.proto diff --git a/shared/definitions.proto b/proto/shared/definitions.proto similarity index 78% rename from shared/definitions.proto rename to proto/shared/definitions.proto index 58028c2..c056c1f 100644 --- a/shared/definitions.proto +++ b/proto/shared/definitions.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +option ruby_package = "Tucana::Shared"; + package shared; message RuntimeFunctionDefinition { From 3cc026493077f67a0b7bdb5404b53a3570ad6320 Mon Sep 17 00:00:00 2001 From: Niklas van Schrick Date: Thu, 29 Aug 2024 20:34:13 +0200 Subject: [PATCH 18/19] Fix ruby build for shared protos --- build/ruby/.gitignore | 2 ++ build/ruby/Rakefile | 61 +++++++++++++++++++++++++--------- build/ruby/spec/tucana_spec.rb | 8 +++++ 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/build/ruby/.gitignore b/build/ruby/.gitignore index cb18a88..5decf0a 100644 --- a/build/ruby/.gitignore +++ b/build/ruby/.gitignore @@ -11,4 +11,6 @@ .rspec_status # generated ruby files +lib/tucana/actions/*.rb lib/tucana/internal/*.rb +lib/tucana/shared/*.rb diff --git a/build/ruby/Rakefile b/build/ruby/Rakefile index c79660b..459c594 100644 --- a/build/ruby/Rakefile +++ b/build/ruby/Rakefile @@ -9,48 +9,77 @@ RSpec::Core::RakeTask.new(:spec) PROJECT_ROOT = File.expand_path("../..", __dir__) RUBY_ROOT = "#{PROJECT_ROOT}/build/ruby".freeze -INPUT_INTERNAL_DIR = "#{PROJECT_ROOT}/internal".freeze +PROTO_ROOT = "#{PROJECT_ROOT}/proto".freeze +INPUT_ACTIONS_DIR = "#{PROTO_ROOT}/actions".freeze +INPUT_INTERNAL_DIR = "#{PROTO_ROOT}/internal".freeze +INPUT_SHARED_DIR = "#{PROTO_ROOT}/shared".freeze +OUTPUT_ACTIONS_DIR = "#{RUBY_ROOT}/lib/tucana/actions".freeze OUTPUT_INTERNAL_DIR = "#{RUBY_ROOT}/lib/tucana/internal".freeze +OUTPUT_SHARED_DIR = "#{RUBY_ROOT}/lib/tucana/shared".freeze def system!(*args) system(*args, exception: true) end namespace :generate_ruby do - desc "Generate ruby files for the internal protocol" - task :internal do - FileUtils.rm_rf(OUTPUT_INTERNAL_DIR) - FileUtils.mkdir_p(OUTPUT_INTERNAL_DIR) + def compile_protos!(input_dir, output_dir) + FileUtils.rm_rf(output_dir) + FileUtils.mkdir_p(output_dir) FileUtils.chdir RUBY_ROOT do - Dir["#{INPUT_INTERNAL_DIR}/*.proto"].each do |file| + Dir["#{input_dir}/*.proto"].each do |file| # rubocop:disable Layout/LineLength - system!("bundle exec grpc_tools_ruby_protoc -I #{INPUT_INTERNAL_DIR} --ruby_out=#{OUTPUT_INTERNAL_DIR} --grpc_out=#{OUTPUT_INTERNAL_DIR} #{file}") + system!("bundle exec grpc_tools_ruby_protoc -I #{input_dir} -I #{INPUT_SHARED_DIR} --ruby_out=#{output_dir} --grpc_out=#{output_dir} #{file}") # rubocop:enable Layout/LineLength end - Dir["#{OUTPUT_INTERNAL_DIR}/*_pb.rb"].each do |file| + + Dir["#{OUTPUT_SHARED_DIR}/*_pb.rb"].each do |shared_file| + shared_file_name = File.basename(shared_file).delete_suffix('.rb') + Dir["#{output_dir}/*_pb.rb"].each do |file| + code = File.read(file) + code = code.gsub("require '#{shared_file_name}'", "require_relative '../shared/#{shared_file_name}'") + File.write(file, code) + end + end + + Dir["#{output_dir}/*_pb.rb"].each do |file| code = File.read(file) code = code.gsub(/require '(\S+)_pb'/, "require_relative '\\1_pb'") - File.write(file, code) + File.write(file, code) end end end + desc "Generate ruby files for shared files between protocols" + task :shared do + compile_protos!(INPUT_SHARED_DIR, OUTPUT_SHARED_DIR) + end + + desc "Generate ruby files for the internal protocol" + task internal: "generate_ruby:shared" do + compile_protos!(INPUT_INTERNAL_DIR, OUTPUT_INTERNAL_DIR) + end + + desc "Generate ruby files for the actions protocol" + task actions: "generate_ruby:shared" do + compile_protos!(INPUT_ACTIONS_DIR, OUTPUT_ACTIONS_DIR) + end + desc "Generate ruby files for all protocols" - task all: ["generate_ruby:internal"] + task all: %w[generate_ruby:internal generate_ruby:actions] end namespace :release do desc "Set the version for the gem" task :version, [:version] do |_, args| File.write("#{RUBY_ROOT}/lib/tucana/version.rb", <<~RUBY) - # frozen_string_literal: true + # frozen_string_literal: true - # this file is managed with the "release:version" task. - # to update the version, run "bundle exec rake release:version[NEW_VERSION]". + # this file is managed with the "release:version" task. + # to update the version, run "bundle exec rake release:version[NEW_VERSION]". - module Tucana - VERSION = "#{args[:version]}" - end + module Tucana + VERSION = "#{args[:version]}" + end RUBY system!("bundle") diff --git a/build/ruby/spec/tucana_spec.rb b/build/ruby/spec/tucana_spec.rb index f4df177..7b8941b 100644 --- a/build/ruby/spec/tucana_spec.rb +++ b/build/ruby/spec/tucana_spec.rb @@ -4,4 +4,12 @@ it "has a version number" do expect(Tucana::VERSION).not_to be_nil end + + it "can load internal protocol" do + expect { Tucana.load_protocol(:internal) }.not_to raise_error + end + + it "can load actions protocol" do + expect { Tucana.load_protocol(:actions) }.not_to raise_error + end end From e458033e27fe23f5b95395c8398198f047490acf Mon Sep 17 00:00:00 2001 From: Niklas van Schrick Date: Fri, 30 Aug 2024 17:43:35 +0200 Subject: [PATCH 19/19] Rename start_node in Flow --- proto/internal/flow.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/internal/flow.proto b/proto/internal/flow.proto index e5e0118..024c2be 100644 --- a/proto/internal/flow.proto +++ b/proto/internal/flow.proto @@ -8,7 +8,7 @@ import "node.proto"; import "flow_definition.proto"; message Flow { - Node starting_node = 2; + Node start_node = 2; FlowDefinition definition = 3; }