- add: character and world proto stubs

This commit is contained in:
2024-12-14 01:55:15 -05:00
parent 4c7a363814
commit 0fd2b0f9b1
4 changed files with 65 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
fn main() {
// gRPC Server code
tonic_build::configure()
.build_server(true) // Generate gRPC server code
.compile_well_known_types(true)
.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]")
.compile_protos(&["../proto/character.proto"], &["../proto"])
.unwrap_or_else(|e| panic!("Failed to compile protos {:?}", e));
// gRPC Client code
tonic_build::configure()
.build_server(false) // Generate gRPC client code
.compile_well_known_types(true)
.compile_protos(&["../proto/database.proto", "../proto/auth.proto"], &["../proto"])
.unwrap_or_else(|e| panic!("Failed to compile protos {:?}", e));
}

16
proto/character.proto Normal file
View File

@@ -0,0 +1,16 @@
syntax = "proto3";
package character;
service CharacterService {
rpc GetCharacterList(CharacterListRequest) returns (CharacterListResponse);
}
message CharacterListRequest {
string token = 1;
string user_id = 2;
}
message CharacterListResponse {
int32 count = 1;
}

17
proto/world.proto Normal file
View File

@@ -0,0 +1,17 @@
syntax = "proto3";
package character;
service CharacterService {
rpc GetCharacter(CharacterRequest) returns (CharacterResponse);
}
message CharacterRequest {
string token = 1;
string user_id = 2;
string char_id = 3;
}
message CharacterResponse {
int32 count = 1;
}

16
world-service/build.rs Normal file
View File

@@ -0,0 +1,16 @@
fn main() {
// gRPC Server code
tonic_build::configure()
.build_server(true) // Generate gRPC server code
.compile_well_known_types(true)
.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]")
.compile_protos(&["../proto/world.proto"], &["../proto"])
.unwrap_or_else(|e| panic!("Failed to compile protos {:?}", e));
// gRPC Client code
tonic_build::configure()
.build_server(false) // Generate gRPC client code
.compile_well_known_types(true)
.compile_protos(&["../proto/database.proto", "../proto/auth.proto"], &["../proto"])
.unwrap_or_else(|e| panic!("Failed to compile protos {:?}", e));
}