Skip to content

Commit

Permalink
Merge pull request #31 from code0-tech/30-action-simplification
Browse files Browse the repository at this point in the history
Action Simplification
  • Loading branch information
raphael-goetz authored Jan 6, 2025
2 parents 2a25928 + 27671f7 commit 72a2218
Show file tree
Hide file tree
Showing 11 changed files with 210 additions and 69 deletions.
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 = "<version>" }
```

To enable additional features::

```toml
[dependencies]
tucana = { version = "<version>", features = ["sagittarius", "aquila"] }
```

### Ruby

See: [Gem](https://rubygems.org/gems/tucana)

```ruby
gem 'tucana', '<version>'
```

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
```
19 changes: 12 additions & 7 deletions build/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
];

Expand Down Expand Up @@ -41,4 +46,4 @@ fn main() -> Result<()> {
.expect("Cannot compile internal protos");

Ok(())
}
}
80 changes: 80 additions & 0 deletions proto/aquila/action_communication.proto
Original file line number Diff line number Diff line change
@@ -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);
}
13 changes: 0 additions & 13 deletions proto/aquila/event.proto

This file was deleted.

33 changes: 0 additions & 33 deletions proto/aquila/transfer.proto

This file was deleted.

3 changes: 1 addition & 2 deletions proto/sagittarius/action.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
import "definitions.proto";
import "runtime_function_definition.proto";

option ruby_package = "Tucana::Sagittarius";

Expand All @@ -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 {}
Expand Down
2 changes: 1 addition & 1 deletion proto/sagittarius/node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 0 additions & 13 deletions proto/shared/definitions.proto

This file was deleted.

28 changes: 28 additions & 0 deletions proto/shared/event.proto
Original file line number Diff line number Diff line change
@@ -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;
}
22 changes: 22 additions & 0 deletions proto/shared/runtime_function_definition.proto
Original file line number Diff line number Diff line change
@@ -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;
}
3 changes: 3 additions & 0 deletions proto/shared/translations.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 72a2218

Please sign in to comment.