- update: character service grpc protocol additions for create, delete and get character with stubs
This commit is contained in:
@@ -11,6 +11,6 @@ fn main() {
|
|||||||
tonic_build::configure()
|
tonic_build::configure()
|
||||||
.build_server(false) // Generate gRPC client code
|
.build_server(false) // Generate gRPC client code
|
||||||
.compile_well_known_types(true)
|
.compile_well_known_types(true)
|
||||||
.compile_protos(&["../proto/user_db_api.proto", "../proto/auth.proto"], &["../proto"])
|
.compile_protos(&["../proto/user_db_api.proto", "../proto/character_db_api.proto", "../proto/auth.proto"], &["../proto"])
|
||||||
.unwrap_or_else(|e| panic!("Failed to compile protos {:?}", e));
|
.unwrap_or_else(|e| panic!("Failed to compile protos {:?}", e));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use tracing::debug;
|
|||||||
use tonic::{Request, Response, Status};
|
use tonic::{Request, Response, Status};
|
||||||
use tracing::field::debug;
|
use tracing::field::debug;
|
||||||
use crate::character_service::character::character_service_server::CharacterService;
|
use crate::character_service::character::character_service_server::CharacterService;
|
||||||
use crate::character_service::character::{Character, GetCharacterListRequest, GetCharacterListResponse};
|
use crate::character_service::character::{Character, CreateCharacterRequest, DeleteCharacterRequest, Empty, GetCharacterListRequest, GetCharacterListResponse, GetCharacterRequest};
|
||||||
|
|
||||||
pub mod character {
|
pub mod character {
|
||||||
tonic::include_proto!("character");
|
tonic::include_proto!("character");
|
||||||
@@ -50,4 +50,16 @@ impl CharacterService for MyCharacterService {
|
|||||||
let response = GetCharacterListResponse { characters };
|
let response = GetCharacterListResponse { characters };
|
||||||
Ok(Response::new(response))
|
Ok(Response::new(response))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn create_character(&self, request: Request<CreateCharacterRequest>) -> Result<Response<Empty>, Status> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn delete_character(&self, request: Request<DeleteCharacterRequest>) -> Result<Response<Empty>, Status> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_character(&self, request: Request<GetCharacterRequest>) -> Result<Response<Empty>, Status> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,9 @@ package character;
|
|||||||
|
|
||||||
service CharacterService {
|
service CharacterService {
|
||||||
rpc GetCharacterList(GetCharacterListRequest) returns (GetCharacterListResponse);
|
rpc GetCharacterList(GetCharacterListRequest) returns (GetCharacterListResponse);
|
||||||
|
rpc CreateCharacter(CreateCharacterRequest) returns (Empty);
|
||||||
|
rpc DeleteCharacter(DeleteCharacterRequest) returns (Empty);
|
||||||
|
rpc GetCharacter(GetCharacterRequest) returns (Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetCharacterListRequest {
|
message GetCharacterListRequest {
|
||||||
@@ -14,6 +17,19 @@ message GetCharacterListResponse {
|
|||||||
repeated Character characters = 1;
|
repeated Character characters = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message CreateCharacterRequest {
|
||||||
|
string user_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeleteCharacterRequest {
|
||||||
|
string user_id = 1;
|
||||||
|
string char_id = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetCharacterRequest {
|
||||||
|
string user_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message Character {
|
message Character {
|
||||||
string character_id = 1; // Unique ID for the character
|
string character_id = 1; // Unique ID for the character
|
||||||
string name = 2; // Name of the character
|
string name = 2; // Name of the character
|
||||||
@@ -32,4 +48,6 @@ message EquippedItem {
|
|||||||
int32 gem_option = 2;
|
int32 gem_option = 2;
|
||||||
int32 socket = 3;
|
int32 socket = 3;
|
||||||
int32 grade = 4;
|
int32 grade = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message Empty {}
|
||||||
|
|||||||
Reference in New Issue
Block a user