Skip to content

Commit

Permalink
feat(rsjudge-grpc): 👔 update proto definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Jisu-Woniu committed Apr 17, 2024
1 parent 003b4bd commit dc770f3
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 13 deletions.
96 changes: 96 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ log.workspace = true
mimalloc = "0.1.39"
tokio = { version = "1.37.0", features = ["fs", "rt-multi-thread", "macros", "process"] }
toml = "0.8.12"
sysinfo = { version = "0.30.10", features = ["serde"] }

# Unused for now:
# cgroups = "0.1.0"
Expand Down
54 changes: 53 additions & 1 deletion crates/rsjudge-grpc/proto/register/v1/register.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,56 @@ syntax = "proto3";
package register.v1;

// The register service definition.
service RegisterService {}
service RegisterService {
// Register a new rsjudge instance.
rpc Register(RegisterRequest) returns (RegisterResponse) {}
}

// Request to register a new rsjudge instance.
message RegisterRequest {
// List of languages supported by the rsjudge instance.
repeated Language 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 {
// 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;
}

// Response to a new registered rsjudge instance.
message RegisterResponse {
// The id for the rsjudge instance.
int32 id = 1;
}

// Fetch cases from backend server.
service CaseService {
// Fetch cases from the backend server.
rpc FetchCases(FetchCasesRequest) returns (FetchCasesResponse) {}
}

// Request to fetch cases from the backend server.
message FetchCasesRequest {
// The id of the problem.
int32 problem_id = 1;
}

// Response to fetch cases from the backend server.
message FetchCasesResponse {
// The id of the cases requested.
int32 cases_id = 1;
// The tarball of the cases, with config file.
//
// TODO: The tarball should be compressed in a specified format.
// Maybe .tar.zst
bytes tarball = 2;
}
42 changes: 30 additions & 12 deletions crates/rsjudge-grpc/proto/rsjudge/v1/rsjudge.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";

package rsjudge.v1;

import "google/protobuf/duration.proto";
import "google/protobuf/empty.proto";

// The judging service definition.
service JudgeService {
Expand All @@ -26,10 +26,12 @@ message SelfTestRequest {
message SelfTestResponse {
// The type of the response.
oneof self_test_response_type {
// Message indicating start of compilation.
google.protobuf.Empty compile_start = 1;
// Message indicating the compile result.
CompileInfo compile_info = 1;
CompileInfo compile_info = 2;
// Message indicating the self-test result.
SelfTestSummary summary = 2;
SelfTestSummary summary = 3;
}
}

Expand Down Expand Up @@ -59,8 +61,10 @@ message SelfTestSummary {
//
// This is not used by the judge system, but may be useful for debugging.
string stderr = 3;
// Execution time of the program. Unset if TLE and killed by judger.
optional google.protobuf.Duration execution_time = 4;
// Execution time of the program, in ms. Unset if TLE and killed by judger.
optional int32 execution_time = 4;
// Memory usage of the program, in kiB. Unset if MLE and killed by judger.
optional int32 memory_usage = 5;
}

// The request containing the user's code and judge info.
Expand All @@ -71,24 +75,28 @@ message SubmitRequest {
string language = 1;
// The code to be judged.
string code = 2;
// The test case id.
// The problem id.
int32 problem_id = 3;
// The cases id.
//
// If the test case is updated, the test case id MUST be changed, so that the judger can request the latest test case.
int32 test_case_id = 3;
int32 cases_id = 4;
}

// The response message containing the judge results.
message SubmitResponse {
// The type of the response.
oneof submit_response_type {
// Message indicating start of compilation.
google.protobuf.Empty compile_start = 1;
// Message indicating the compile result.
CompileInfo compile_info = 1;
CompileInfo compile_info = 2;
// Message indicating the single case judge result.
//
// Case info may not be sent in order, so case id SHOULD be checked.
CaseInfo case_info = 2;
CaseInfo case_info = 3;
// Message indicating the judge result of all cases.
CasesSummary cases_summary = 3;
CasesSummary cases_summary = 4;
}
}

Expand Down Expand Up @@ -120,8 +128,18 @@ enum JudgeResult {
JUDGE_RESULT_UNSPECIFIED = 0;
// The judge result is Accepted (AC).
JUDGE_RESULT_ACCEPTED = 1;
// The judge result is Compilation Error (CE).
JUDGE_RESULT_COMPILE_ERROR = 2;
// The judge result is Wrong Answer (WA).
JUDGE_RESULT_WRONG_ANSWER = 2;
JUDGE_RESULT_WRONG_ANSWER = 3;
// The judge result is Presentation Error (PE).
JUDGE_RESULT_PRESENTATION_ERROR = 4;
// The judge result is Runtime Error (RE).
JUDGE_RESULT_RUNTIME_ERROR = 3;
JUDGE_RESULT_RUNTIME_ERROR = 5;
// The judge result is Time Limit Exceeded (TLE).
JUDGE_RESULT_TIME_LIMIT_EXCEEDED = 6;
// The judge result is Memory Limit Exceeded (MLE).
JUDGE_RESULT_MEMORY_LIMIT_EXCEEDED = 7;
// The judge result is Output Limit Exceeded (OLE).
JUDGE_RESULT_OUTPUT_LIMIT_EXCEEDED = 8;
}

0 comments on commit dc770f3

Please sign in to comment.