Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement datatypes into sagittarius protocol #17

Merged
merged 3 commits into from
Nov 25, 2024
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
10 changes: 9 additions & 1 deletion build/ruby/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ namespace :generate_ruby do

Dir["#{output_dir}/*_pb.rb"].each do |file|
code = File.read(file)
code = code.gsub(/require '(\S+)_pb'/, "require_relative '\\1_pb'")
code = code.gsub(/require '(\S+)_pb'/) do |str|
match = Regexp.last_match[1]

if File.exist?("#{output_dir}/#{match}_pb.rb")
"require_relative '#{match}_pb'"
else
str
end
end
File.write(file, code)
end
end
Expand Down
18 changes: 18 additions & 0 deletions proto/sagittarius/datatype.proto
raphael-goetz marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = "proto3";
import "datatype_definition.proto";

option ruby_package = "Tucana::Sagittarius";

package sagittarius;

message DataTypeUpdateRequest {
repeated shared.DataType data_types = 1;
}

message DataTypeUpdateResponse {
bool success = 1;
}

service DataTypeService {
rpc Update(DataTypeUpdateRequest) returns (DataTypeUpdateResponse) {}
}
41 changes: 41 additions & 0 deletions proto/shared/datatype_definition.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
syntax = "proto3";
import "google/protobuf/any.proto";
import "translations.proto";

option ruby_package = "Tucana::Shared";

package shared;

message DataType {
enum Variant {
UNKNOWN = 0;
PRIMITIVE = 1;
TYPE = 2;
OBJECT = 3;
DATATYPE = 4;
ARRAY = 5;
GENERIC = 6;
FUNCTION = 7;
}

Translation name = 1;
Variant variant = 2;
repeated DataTypeRule rules = 3;
repeated DataType input_types = 4;
optional DataType return_type = 5;
optional DataType parent_type = 6;
}

message DataTypeRule {
enum Variant {
UNKNOWN = 0;
REGEX = 1;
NUMBER_RANGE = 2;
ITEM_OF_COLLECTION = 3;
CONTAINS_TYPE = 4;
CONTAINS_KEY = 5;
}

Variant variant = 1;
map<string, google.protobuf.Any> config = 2;
}
10 changes: 10 additions & 0 deletions proto/shared/translations.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
syntax = "proto3";

option ruby_package = "Tucana::Shared";

package shared;

message Translation {
string code = 1;
string text = 2;
}