Skip to content

Commit

Permalink
feat(rsjudge-grpc): ✨ update protobuf for more flexible language decl…
Browse files Browse the repository at this point in the history
…aration
  • Loading branch information
Jisu-Woniu committed May 13, 2024
1 parent 15fc297 commit 71847a1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
19 changes: 19 additions & 0 deletions crates/rsjudge-grpc/proto/judge/v1/judge.proto
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,22 @@ enum JudgeResult {
// The judge result is Output Limit Exceeded (OLE).
JUDGE_RESULT_OUTPUT_LIMIT_EXCEEDED = 8;
}

// Represents a language supported by the judge system.
message Language {
// The slug of the language.
string slug = 1;
// Additional configuration for the language.
map<string, ConfigType> configs = 4;
}

// Represents type of the configuration item.
message ConfigType {
// The type of the configuration item.
oneof config_type {
// The configuration item is a boolean.
bool boolean = 1;
// The configuration item is an enum. The value must be one of the specified variants.
string enum = 2;
}
}
33 changes: 27 additions & 6 deletions crates/rsjudge-grpc/proto/register/v1/register.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package register.v1;

import "google/protobuf/empty.proto";

// The register service definition.
service RegisterService {
// Register a new rsjudge instance.
Expand All @@ -11,21 +13,40 @@ service RegisterService {
// Request to register a new rsjudge instance.
message RegisterRequest {
// List of languages supported by the rsjudge instance.
repeated Language languages = 1;
repeated LanguageDecl languages = 1;
// The address of the backend server.
int32 port = 2;
// System information. (maybe in JSON)
string system_info = 3;
}

// A language supported by the rsjudge instance.
message Language {
message LanguageDecl {
// The name of the language.
string name = 1;
// The highlight scheme of the language.
string language_base = 2;
// The file extension of the language.
optional string info = 3;
// The highlight scheme of the language, should match one of [CodeMirror modes](https://github.com/codemirror/codemirror5/tree/master/mode).
string highlight_scheme = 2;
// A canonical name of the language.
string slug = 3;
// Optional configurations for the language.
map<string, ConfigTypeDecl> configs = 4;
}

// Configuration for a language.
message ConfigTypeDecl {
// Type of value for the configuration.
oneof config_type {
// Value is a boolean.
google.protobuf.Empty boolean = 1;
// Value is an enum.
EnumDecl enum = 2;
}
}

// Message for an enum configuration.
message EnumDecl {
// Variants of the enum.
repeated string variants = 1;
}

// Response to a new registered rsjudge instance.
Expand Down

0 comments on commit 71847a1

Please sign in to comment.