-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
Description
🔌 gRPC 기반 마이크로서비스 간 통신 구축
📋 Issue Overview
현재 메인 서버(application)와 casper-user 간의 통신은 Feign Client를 사용하고 있습니다. 성능 최적화와 타입 안전성 확보를 위해 gRPC 기반 통신으로 전환하여 더 효율적인 마이크로서비스 간 통신 환경을 구축하고자 합니다.
🎯 Goals
- 성능 향상: HTTP/2 기반 gRPC로 통신 성능 개선
- 타입 안전성: Protocol Buffers를 통한 강타입 인터페이스 보장
- 개발 효율성: 자동 코드 생성으로 클라이언트/서버 스텁 생성
📊 Current vs Target Architecture
Current State (Feign Client):
@FeignClient(name = "UserClient", url = "\${url.user}")
interface UserClient {
@GetMapping("/user/{userId}")
fun getUserInfoByUserId(@PathVariable("userId") userId: UUID): UserInfoElement
}
Target State (gRPC):
protobufservice UserService {
rpc GetUserInfoByUserId(GetUserInfoRequest) returns (GetUserInfoResponse);
}
🏗️ Technical Implementation
Dependencies Configuration - build.gradle.kts:
kotlindependencies {
// gRPC Core
implementation("io.grpc:grpc-netty-shaded:${DependencyVersion.GRPC}")
implementation("io.grpc:grpc-protobuf:${DependencyVersion.GRPC}")
implementation("io.grpc:grpc-stub:${DependencyVersion.GRPC}")
// gRPC Kotlin Support
implementation("io.grpc:grpc-kotlin-stub:${DependencyVersion.GRPC_KOTLIN}")
implementation("com.google.protobuf:protobuf-kotlin:${DependencyVersion.PROTOBUF}")
}
Version Compatibility:
gRPC Java: 1.61.1
gRPC Kotlin: 1.4.1
Protocol Buffers: 3.25.3
Protobuf Gradle Plugin: 0.9.4
Protocol Buffers Definition - casper-user/src/main/proto/user.proto:
protobufsyntax = "proto3";
package casper.user;
option java_package = "hs.kr.entrydsm.casper.user.proto";
option java_outer_classname = "UserServiceProto";
service UserService {
rpc GetUserInfoByUserId(GetUserInfoRequest) returns (GetUserInfoResponse);
}
message GetUserInfoRequest {
string user_id = 1; // UUID as string
}
message GetUserInfoResponse {
string id = 1;
string phone_number = 2;
string name = 3;
bool is_parent = 4;
UserRole role = 5;
}
enum UserRole {
UNSPECIFIED = 0;
ROOT = 1;
USER = 2;
ADMIN = 3;
}
| Protobuf Plugin Setup:
kotlinprotobuf {
protoc {
artifact = "com.google.protobuf:protoc:${DependencyVersion.PROTOBUF}"
}
plugins {
create("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:${DependencyVersion.GRPC}"
}
create("grpckt") {
artifact = "io.grpc:protoc-gen-grpc-kotlin:${DependencyVersion.GRPC_KOTLIN}:jdk8@jar"
}
}
generateProtoTasks {
all().forEach {
it.plugins {
create("grpc")
create("grpckt")
}
}
}
}