diff --git a/README.md b/README.md new file mode 100644 index 0000000..ad70031 --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +# Tucana + +This repository is responsible for all gRPC definitions that we use. + +## Setup + +See the setup guide for the following languages. Support for other languages is not planed! + +### Rust + +See: [Crate](https://crates.io/crates/tucana) + +```toml +[dependencies] +tucana = { version = "" } +``` + +To enable additional features:: + +```toml +[dependencies] +tucana = { version = "", features = ["sagittarius", "aquila"] } +``` + +### Ruby + +See: [Gem](https://rubygems.org/gems/tucana) + +```ruby +gem 'tucana', '' +``` + +Don't forget to initialize the required feature: +```ruby +# For Sagittarius +Tucana.load_protocol(:sagittarius) + +# For Aquila +Tucana.load_protocol(:aquila) +``` + +## Project Structure + +The project is organized with services functioning as servers. Each protocol in the Sagittarius folder corresponds to +services that Sagittarius must implement as a server. + +```ascii-tree +. +├── aquila +│ ├── action - Action service (emits events, manages configs, and handles executions) +│ └── execution - Execution service (handles internal execution calls) +├── sagittarius +│ ├── action - Action service (manages logon/logoff requests for action configurations) +│ ├── datatype - DataType service +│ ├── flow - Flow service (handles flow updates) +│ ├── flow_definition - Defines types for flows +│ ├── node - Defines types for nodes +│ └── ping - Ping service (performs life checks) +└── shared + ├── datatype_definition - Defines types for data types + ├── runtime_function_definition - Defines types for runtime functions + └── translations - Contains translations with country codes and translated messages +``` \ No newline at end of file diff --git a/build/rust/build.rs b/build/rust/build.rs index 3d9f519..5c709ff 100644 --- a/build/rust/build.rs +++ b/build/rust/build.rs @@ -2,16 +2,21 @@ use std::fs::create_dir; use std::io::Result; fn main() -> Result<()> { - let proto = &[ - "definitions.proto", + // aquila + "action_communication.proto", + "action_execute.proto", + // sagittarius + "action.proto", + "datatype.proto", + "flow.proto", "flow_definition.proto", "node.proto", - "flow.proto", - "action.proto", - "transfer.proto", "ping.proto", - "action_execute.proto", + // shared + "datatype_definition.proto", + "runtime_function_definition.proto", + "translations.proto", "event.proto" ]; @@ -41,4 +46,4 @@ fn main() -> Result<()> { .expect("Cannot compile internal protos"); Ok(()) -} \ No newline at end of file +} diff --git a/proto/aquila/action_communication.proto b/proto/aquila/action_communication.proto new file mode 100644 index 0000000..2a6b1b9 --- /dev/null +++ b/proto/aquila/action_communication.proto @@ -0,0 +1,80 @@ +syntax = "proto3"; + +import "google/protobuf/struct.proto"; +import "runtime_function_definition.proto"; +import "datatype_definition.proto"; +import "translations.proto"; +import "event.proto"; + +option ruby_package = "Tucana::Aquila"; + +package aquila; + +// Event that gets admitted by an action +message Event { + // Id of Event type + string event_type = 1; + // Payload (JSON) of event params + google.protobuf.Value payload = 2; +} + +// Action flow/event configuration +message Configuration { + // Action identifier + string identifier = 1; + // Flow Configuration + repeated shared.RuntimeFunctionDefinition function_definitions = 2; + // Event Configuration + repeated shared.EventType event_types = 3; + // Application Configuration + repeated ActionConfiguration action_configurations = 4; +} + +message ActionConfiguration { + repeated shared.Translation name = 1; + repeated shared.Translation description = 2; + shared.DataType type = 3; + optional google.protobuf.Value default_value = 4; +} + +// Request to execute a request a flow +message ExecutionRequest { + // Execution identifier of execution + string execution_identifier = 1; + // Function identifier of flow to execute + string function_identifier = 2; + // Parameters (JSON) of flow required to execute + google.protobuf.Struct parameters = 3; +} + +// Result from executed flows by an action +message ExecutionResult { + // Identifier of flow to execute + string execution_identifier = 1; + // Result of executed flow + google.protobuf.Value result = 2; +} + +message TransferRequest { + oneof data { + // Configuration of action that will be send to sagittarius + // + // Expected behavior: + // Aquila will abort if the first request is not a configuration + Configuration configuration = 1; + // Event that got admitted + Event event = 2; + // Result of execution that was triggered by a execution request + ExecutionResult result = 3; + } +} + +message TransferResponse { + // Execution request + ExecutionRequest execution = 1; +} + +service ActionTransferService { + // This behavior achieves a bi-directional stream so that both services aren't required to be a server & client on their own + rpc Transfer (stream TransferRequest) returns (stream TransferResponse); +} \ No newline at end of file diff --git a/proto/aquila/event.proto b/proto/aquila/event.proto deleted file mode 100644 index 917150c..0000000 --- a/proto/aquila/event.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; - -option ruby_package = "Tucana::Aquila"; - -package aquila; - -// Event that gets admitted by an action -message Event { - // Id of Event type - string event_type = 1; - // Payload (JSON) of event params - string payload = 2; -} \ No newline at end of file diff --git a/proto/aquila/transfer.proto b/proto/aquila/transfer.proto deleted file mode 100644 index afd8a94..0000000 --- a/proto/aquila/transfer.proto +++ /dev/null @@ -1,33 +0,0 @@ -syntax = "proto3"; - -import "definitions.proto"; - -option ruby_package = "Tucana::Aquila"; - -package aquila; - -message InformationRequest { - string identifier = 1; - repeated shared.RuntimeFunctionDefinition function_definition = 2; - repeated shared.RuntimeParameterDefinition parameter_definition = 3; -} - -message InformationResponse { - bool success = 1; -} - -message ActionExecuteRequest { - string execution_identifier = 1; - string function_identifier = 2; - repeated string parameters = 3; -} - -message ActionExecuteResponse { - string execution_identifier = 1; - repeated string result = 2; -} - -service ActionTransferService { - rpc Transfer (stream InformationRequest) returns (InformationResponse); - rpc Execute (stream ActionExecuteRequest) returns (stream ActionExecuteResponse); -} \ No newline at end of file diff --git a/proto/sagittarius/action.proto b/proto/sagittarius/action.proto index 81b801a..fa1e819 100644 --- a/proto/sagittarius/action.proto +++ b/proto/sagittarius/action.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -import "definitions.proto"; +import "runtime_function_definition.proto"; option ruby_package = "Tucana::Sagittarius"; @@ -8,7 +8,6 @@ package sagittarius; message ActionLogonRequest { string identifier = 1; repeated shared.RuntimeFunctionDefinition function_definition = 2; - repeated shared.RuntimeParameterDefinition parameter_definition = 3; } message ActionLogonResponse {} diff --git a/proto/sagittarius/node.proto b/proto/sagittarius/node.proto index a3024f9..994275d 100644 --- a/proto/sagittarius/node.proto +++ b/proto/sagittarius/node.proto @@ -4,7 +4,7 @@ option ruby_package = "Tucana::Sagittarius"; package sagittarius; -import "definitions.proto"; +import "runtime_function_definition.proto"; message Node { shared.RuntimeFunctionDefinition definition = 1; diff --git a/proto/shared/definitions.proto b/proto/shared/definitions.proto deleted file mode 100644 index c056c1f..0000000 --- a/proto/shared/definitions.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; - -option ruby_package = "Tucana::Shared"; - -package shared; - -message RuntimeFunctionDefinition { - string id = 1; -} - -message RuntimeParameterDefinition { - string name = 1; -} \ No newline at end of file diff --git a/proto/shared/event.proto b/proto/shared/event.proto new file mode 100644 index 0000000..e0f8cdc --- /dev/null +++ b/proto/shared/event.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; + +import "google/protobuf/struct.proto"; +import "translations.proto"; +import "datatype_definition.proto"; + +option ruby_package = "Tucana::Shared"; + +package shared; + +message EventDefinitionSettings { + repeated Translation name = 1; + bool unique = 2; + repeated Translation description = 3; + DataType type = 4; + optional google.protobuf.Value default_value = 5; +} + +message EventDefinition { + repeated EventDefinitionSettings settings = 1; + DataType input_type = 2; + bool editable = 3; +} + +message EventType { + repeated Translation name = 1; + EventDefinition definition = 2; +} diff --git a/proto/shared/runtime_function_definition.proto b/proto/shared/runtime_function_definition.proto new file mode 100644 index 0000000..7ee62b8 --- /dev/null +++ b/proto/shared/runtime_function_definition.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +import "datatype_definition.proto"; + +option ruby_package = "Tucana::Shared"; + +package shared; + +message RuntimeFunctionDefinition { + string runtime_id = 1; + optional RuntimeParameterDefinitions runtime_parameter_definitions = 2; + optional DataType return_type = 3; +} + +message RuntimeParameterDefinitions { + repeated RuntimeFunctionDefinition parameters = 1; +} + +message RuntimeParameterDefinition { + DataType type = 1; + string name = 2; +} \ No newline at end of file diff --git a/proto/shared/translations.proto b/proto/shared/translations.proto index 973f43f..70d53d6 100644 --- a/proto/shared/translations.proto +++ b/proto/shared/translations.proto @@ -4,7 +4,10 @@ option ruby_package = "Tucana::Shared"; package shared; +// Translation to translate flows, description etc... message Translation { + // Language code (e.g. de_DE) string code = 1; + // Translated content string content = 2; }