<aside> 💡
gRPC + Armeria + Dagger 기반 서비스 흐름 문서 SquareLab [ Groot ] 업무 흐름
</aside>
본 문서는 gRPC, Armeria, Dagger를 사용하여 gRPC 서비스 생성 흐름을 설명합니다.
.proto
파일 생성 ( API의 요청 및 응답 메시지, 메서드를 정의 )
hello_service.proto
→ Service 와 rpc method 정의
hello.proto
→ rpc method 에서 직접적으로 사용되는 request/response 정의hello_base.proto
( optional ) → request/response 이외의 하위 메시지 정의protoc
을 사용하여 Stub(서비스 인터페이스) 생성
CoroutineStub
활용 → 자체 gradle plugin Proto3Plugin
@Module
을 통해 서비스 인스턴스를 제공@Component
를 사용하여 DI 적용GrpcService.builder().addService(helloService)
형태로 서버 등록Server.builder().http(8080).service(GrpcService).build()
실행.proto
파일을 작성하여 gRPC API 요청 및 응답 메시지를 정의합니다.
syntax = "proto3";
package example;
service HelloService {
rpc SayHello (HelloRequest) returns (HelloResponse);
}
message HelloRequest {
string name = 1;
}
message HelloResponse {
string message = 1;
}
.proto
파일을 protoc
컴파일러로 변환하여, Kotlin(Java) Stub 코드를 생성합니다.
HelloServiceGrpc
HelloServiceGrpcKt