File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ dependencies {
5151 compileOnly ' org.projectlombok:lombok'
5252 compileOnly ' jakarta.annotation:jakarta.annotation-api:2.1.1'
5353 compileOnly ' javax.annotation:javax.annotation-api:1.3.2'
54- developmentOnly ' org.springframework.boot:spring-boot-devtools'
54+ // developmentOnly 'org.springframework.boot:spring-boot-devtools'
5555 runtimeOnly ' com.mysql:mysql-connector-j'
5656 annotationProcessor ' org.projectlombok:lombok'
5757
@@ -92,7 +92,7 @@ protobuf {
9292 }
9393 }
9494 generateProtoTasks {
95- all(). configureEach { task ->
95+ all(). each { task ->
9696 task. plugins {
9797 grpc {}
9898 }
@@ -104,7 +104,6 @@ def querydslDir = layout.buildDirectory.dir("generated/querydsl").get().asFile
104104
105105sourceSets {
106106 main {
107- proto { srcDir " src/main/proto" }
108107 java {
109108 srcDirs querydslDir,
110109 " $buildDir /generated/sources/proto/main/java" ,
Original file line number Diff line number Diff line change 1+ package flipnote .group .adapter .in .grpc ;
2+
3+ import org .springframework .grpc .server .service .GrpcService ;
4+
5+ import flipnote .group .application .port .in .FindGroupNameUseCase ;
6+ import flipnote .group .grpc .v1 .GetGroupNameRequest ;
7+ import flipnote .group .grpc .v1 .GetGroupNameResponse ;
8+ import flipnote .group .grpc .v1 .GroupCommandServiceGrpc ;
9+ import io .grpc .stub .StreamObserver ;
10+ import lombok .RequiredArgsConstructor ;
11+
12+ @ GrpcService
13+ @ RequiredArgsConstructor
14+ public class GroupCommandService extends GroupCommandServiceGrpc .GroupCommandServiceImplBase {
15+
16+ private final FindGroupNameUseCase findGroupNameUseCase ;
17+
18+ @ Override
19+ public void getGroupName (GetGroupNameRequest request , StreamObserver <GetGroupNameResponse > responseObserver ) {
20+ try {
21+ String groupName = findGroupNameUseCase .findGroupName (request .getGroupId ());
22+
23+ GetGroupNameResponse res = GetGroupNameResponse .newBuilder ()
24+ .setGroupName (groupName )
25+ .build ();
26+
27+ responseObserver .onNext (res );
28+ responseObserver .onCompleted ();
29+ } catch (Exception e ) {
30+ responseObserver .onError (e );
31+ }
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ package flipnote .group .application .port .in ;
2+
3+ public interface FindGroupNameUseCase {
4+ String findGroupName (Long groupId );
5+ }
Original file line number Diff line number Diff line change 1+ package flipnote .group .application .service ;
2+
3+ import java .util .NoSuchElementException ;
4+
5+ import org .springframework .stereotype .Service ;
6+
7+ import flipnote .group .adapter .out .entity .GroupEntity ;
8+ import flipnote .group .application .port .in .FindGroupNameUseCase ;
9+ import flipnote .group .application .port .out .GroupRepositoryPort ;
10+ import lombok .RequiredArgsConstructor ;
11+
12+ @ Service
13+ @ RequiredArgsConstructor
14+ public class FindGroupNameService implements FindGroupNameUseCase {
15+
16+ private final GroupRepositoryPort groupRepository ;
17+
18+ /**
19+ * 그룹 명 조회
20+ * @param groupId
21+ * @return
22+ */
23+ @ Override
24+ public String findGroupName (Long groupId ) {
25+
26+ GroupEntity group = groupRepository .findById (groupId );
27+
28+ if (group == null ) {
29+ throw new NoSuchElementException ("Group not found: " + groupId );
30+ }
31+
32+ return group .getName ();
33+ }
34+ }
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ public class GrpcClientConfig {
1313
1414 @ Bean (destroyMethod = "shutdownNow" )
1515 public ManagedChannel imageCommandChannel (
16- @ Value ("${grpc.image.address:localhost:9092}" ) String target
16+ @ Value ("${spring. grpc.image.address:localhost:9092}" ) String target
1717 ) {
1818 return ManagedChannelBuilder .forTarget (target )
1919 .usePlaintext ()
Original file line number Diff line number Diff line change 1+ syntax = "proto3" ;
2+
3+ package group.v1 ;
4+
5+
6+ option java_multiple_files = true ;
7+ option java_package = "flipnote.group.grpc.v1" ;
8+ option java_outer_classname = "GroupServiceProto" ;
9+
10+ service GroupCommandService {
11+
12+ // 그룹 이름 조회
13+ rpc GetGroupName (GetGroupNameRequest ) returns (GetGroupNameResponse );
14+ }
15+
16+ message GetGroupNameRequest {
17+ int64 group_id = 1 ;
18+ }
19+
20+ message GetGroupNameResponse {
21+ string group_name = 1 ;
22+ }
You can’t perform that action at this time.
0 commit comments