-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/20 dev gRPC #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0de70fa
feat ( #20 ) : InternalAdminResponse
coehgns cd3e381
feat ( #20 ) : AdminGrpcClient
coehgns e852472
feat ( #20 ) : admin.proto
coehgns 31dbbfa
chore ( #20 ) : ๋๋ฝ๋ ์ปค๋ฐ
coehgns 92bcf33
build ( #20 ) : gRPC Dependencies ์ถ๊ฐ
coehgns 8d42d7f
build ( #20 ) : gRPC DependenciesVersion ์ถ๊ฐ
coehgns 2a2567c
build ( #20 ) : kotlin version ์์
coehgns c1d20e2
build ( #20 ) : detekt.yml ์์
coehgns c8474fc
build ( #20 ) : ๋๋ฝ๋ ์ปค๋ฐ
coehgns e6775e7
feat ( #20 ) : admin.proto ํจํค์ง ๋ค์ด๋ฐ ์์
coehgns e869946
build ( #20 ) : Dependencies์ ์์กด์ฑ ์คํ ์์
coehgns 3dd4807
build ( #20 ) : DependencyVersion์ ์์กด์ฑ ์คํ ์์
coehgns fc0d926
build ( #20 ) : Dependencies์ ์ฝ๋ฃจํด ์ถ๊ฐ
coehgns 160a967
build ( #20 ) : DependencyVersion์ ์ฝ๋ฃจํด ์ถ๊ฐ
coehgns 0c6f6bd
build ( #20 ) : ์ฝ๋ฃจํด ์์กด์ฑ ์ถ๊ฐ
coehgns f2bac81
refactor ( #20 ) : Stub์ ๋น๋๊ธฐ ์ฒ๋ฆฌ์ ๋ง๊ฒ ๋ก์ง ์์
coehgns 983b933
chore ( #20 ) : Dependencies์ ๋ถํ์ํ ์์กด์ฑ ์ญ์
coehgns 2907e9b
chore ( #20 ) : DependencyVersion์ ๋ถํ์ํ ์์กด์ฑ ์ญ์
coehgns b175734
refactor ( #20 ) : AdminGrpcClient.kt
coehgns File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| object PluginVersion { | ||
| const val KOTLIN_VERSION = "1.9.25" | ||
| const val KOTLIN_VERSION = "1.9.23" | ||
| const val SPRING_BOOT_VERSION = "3.4.4" | ||
| const val SPRING_DEPENDENCY_MANAGEMENT_VERSION = "1.1.7" | ||
| const val DETEKT_VERSION = "1.23.6" | ||
| const val KTLINT_VERSION = "12.1.1" | ||
| const val PROTOBUF_VERSION = "0.9.4" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| plugins { | ||
| id(Plugin.KOTLIN_JVM) version PluginVersion.KOTLIN_VERSION | ||
| id(Plugin.KOTLIN_SPRING) version PluginVersion.KOTLIN_VERSION | ||
| id(Plugin.KOTLIN_KAPT) | ||
| id(Plugin.SPRING_BOOT) version PluginVersion.SPRING_BOOT_VERSION | ||
| id(Plugin.SPRING_DEPENDENCY_MANAGEMENT) version PluginVersion.SPRING_DEPENDENCY_MANAGEMENT_VERSION | ||
| id(Plugin.CASPER_DOCUMENTATION) | ||
| id(Plugin.PROTOBUF) version PluginVersion.PROTOBUF_VERSION | ||
| } | ||
|
|
||
| group = "hs.kr.entrydsm" | ||
| version = "0.0.1-SNAPSHOT" | ||
|
|
||
| java { | ||
| toolchain { | ||
| languageVersion = JavaLanguageVersion.of(17) | ||
| } | ||
| } | ||
|
|
||
| repositories { | ||
| mavenCentral() | ||
| } | ||
|
|
||
| dependencies { | ||
| // ์คํ๋ง ๋ถํธ ๊ธฐ๋ณธ ๊ธฐ๋ฅ | ||
| implementation(Dependencies.SPRING_BOOT_STARTER) | ||
|
|
||
| // ์ฝํ๋ฆฐ ๋ฆฌํ๋ ์ | ||
| implementation(Dependencies.KOTLIN_REFLECT) | ||
|
|
||
| // ์คํ๋ง ๋ถํธ ํ ์คํธ ๋๊ตฌ | ||
| testImplementation(Dependencies.SPRING_BOOT_STARTER_TEST) | ||
|
|
||
| // ์ฝํ๋ฆฐ + JUnit5 ํ ์คํธ | ||
| testImplementation(Dependencies.KOTLIN_TEST_JUNIT5) | ||
|
|
||
| // JUnit5 ์คํ ๋ฐ์ฒ | ||
| testRuntimeOnly(Dependencies.JUNIT_PLATFORM_LAUNCHER) | ||
|
|
||
| // ์น ๊ด๋ จ | ||
| implementation(Dependencies.SPRING_BOOT_STARTER_WEB) | ||
|
|
||
| // ๋ฐ์ดํฐ๋ฒ ์ด์ค | ||
| implementation(Dependencies.SPRING_BOOT_STARTER_DATA_JPA) | ||
| implementation(Dependencies.SPRING_BOOT_STARTER_DATA_REDIS) | ||
| runtimeOnly(Dependencies.MYSQL_CONNECTOR) | ||
|
|
||
| // ๋ณด์ | ||
| implementation(Dependencies.SPRING_BOOT_STARTER_SECURITY) | ||
|
|
||
| // ๊ฒ์ฆ | ||
| implementation(Dependencies.SPRING_BOOT_STARTER_VALIDATION) | ||
|
|
||
| // JSON ์ฒ๋ฆฌ | ||
| implementation(Dependencies.JACKSON_MODULE_KOTLIN) | ||
| implementation(Dependencies.ORG_JSON) | ||
|
|
||
| // JWT | ||
| implementation(Dependencies.JWT_API) | ||
| implementation(Dependencies.JWT_IMPL) | ||
| runtimeOnly(Dependencies.JWT_JACKSON) | ||
|
|
||
| implementation(Dependencies.MAPSTRUCT) | ||
| kapt(Dependencies.MAPSTRUCT_PROCESSOR) | ||
|
|
||
| // grpc | ||
| implementation(Dependencies.GRPC_NETTY_SHADED) | ||
| implementation(Dependencies.GRPC_PROTOBUF) | ||
| implementation(Dependencies.GRPC_STUB) | ||
| implementation(Dependencies.GRPC_KOTLIN_STUB) | ||
| implementation(Dependencies.PROTOBUF_KOTLIN) | ||
| testImplementation(Dependencies.GRPC_TESTING) | ||
| implementation(Dependencies.GRPC_CLIENT) | ||
| implementation(Dependencies.GOOGLE_PROTOBUF) | ||
|
|
||
| // ์ฝ๋ฃจํด | ||
| implementation(Dependencies.COROUTINES) | ||
|
|
||
| // swagger | ||
| implementation(Dependencies.SWAGGER) | ||
|
|
||
| // aws | ||
| implementation(Dependencies.AWS) | ||
|
|
||
| // feign | ||
| implementation(Dependencies.OPEN_FEIGN) | ||
|
|
||
| // Kafka | ||
| implementation(Dependencies.KAFKA) | ||
| implementation("org.springframework.kafka:spring-kafka:3.1.2") | ||
|
|
||
| // Cloud Config | ||
| // implementation(Dependencies.CLOUD_CONFIG) | ||
| } | ||
|
|
||
| protobuf { | ||
| 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") | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } | ||
|
|
||
| kotlin { | ||
| compilerOptions { | ||
| freeCompilerArgs.addAll("-Xjsr305=strict") | ||
| } | ||
| } | ||
|
|
||
| tasks.withType<Test> { | ||
| useJUnitPlatform() | ||
| } |
56 changes: 56 additions & 0 deletions
56
...er-feed/src/main/kotlin/hs/kr/entrydsm/feed/infrastructure/grpc/client/AdminGrpcClient.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package hs.kr.entrydsm.feed.infrastructure.grpc.client | ||
|
|
||
| import hs.kr.entrydsm.casper.admin.proto.AdminServiceGrpc | ||
| import hs.kr.entrydsm.casper.admin.proto.AdminServiceProto | ||
| import hs.kr.entrydsm.feed.infrastructure.grpc.client.dto.response.InternalAdminResponse | ||
| import io.grpc.Channel | ||
| import io.grpc.stub.StreamObserver | ||
| import kotlinx.coroutines.suspendCancellableCoroutine | ||
| import net.devh.boot.grpc.client.inject.GrpcClient | ||
| import org.springframework.stereotype.Component | ||
| import java.util.UUID | ||
| import kotlin.coroutines.resume | ||
| import kotlin.coroutines.resumeWithException | ||
|
|
||
| /** | ||
| * ๊ด๋ฆฌ์ ์๋น์ค์์ gRPC ํต์ ์ ๋ด๋นํ๋ ํด๋ผ์ด์ธํธ ํด๋์ค์ ๋๋ค. | ||
| * | ||
| * @property channel gRPC ํต์ ์ ์ํ ์ฑ๋ (user-service๋ก ์๋ ์ฃผ์ ๋จ) | ||
| */ | ||
| @Component | ||
| class AdminGrpcClient { | ||
|
|
||
| @GrpcClient("user-service") | ||
| lateinit var channel: Channel | ||
coehgns marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * ๊ด๋ฆฌ์ ID๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ๊ด๋ฆฌ์ ์ ๋ณด๋ฅผ ๋น๋๊ธฐ์ ์ผ๋ก ์กฐํํฉ๋๋ค. | ||
| * gRPC ๋น๋๊ธฐ ์คํธ๋ฆฌ๋ฐ์ ์ฌ์ฉํ์ฌ ๊ด๋ฆฌ์ ์๋น์ค๋ก๋ถํฐ ์ ๋ณด๋ฅผ ๊ฐ์ ธ์ต๋๋ค. | ||
| * | ||
| * @param adminId ์กฐํํ ๊ด๋ฆฌ์์ ๊ณ ์ ์๋ณ์(UUID) | ||
| * @return ์กฐํ๋ ๊ด๋ฆฌ์ ์ ๋ณด๋ฅผ ๋ด์ [InternalAdminResponse] ๊ฐ์ฒด | ||
| * @throws io.grpc.StatusRuntimeException gRPC ์๋ฒ์์ ์ค๋ฅ๊ฐ ๋ฐ์ํ ๊ฒฝ์ฐ | ||
| * @throws java.util.concurrent.CancellationException ์ฝ๋ฃจํด์ด ์ทจ์๋ ๊ฒฝ์ฐ | ||
| */ | ||
| suspend fun getAdminInfoByAdminId(adminId: UUID): InternalAdminResponse { | ||
| val adminStub = AdminServiceGrpc.newStub(channel) | ||
|
|
||
| val request = AdminServiceProto.GetAdminIdRequest.newBuilder() | ||
| .setAdminId(adminId.toString()) | ||
| .build() | ||
|
|
||
| val response = suspendCancellableCoroutine { continuation -> | ||
| adminStub.getAdminByUUID(request, object : StreamObserver<AdminServiceProto.GetAdminIdResponse> { | ||
| override fun onNext(value: AdminServiceProto.GetAdminIdResponse) { | ||
| continuation.resume(value) | ||
| } | ||
| override fun onError(t: Throwable) { | ||
| continuation.resumeWithException(t) | ||
| } | ||
| override fun onCompleted() {} | ||
| }) | ||
| } | ||
|
|
||
| return InternalAdminResponse(id = UUID.fromString(response.adminId)) | ||
| } | ||
| } | ||
12 changes: 12 additions & 0 deletions
12
...tlin/hs/kr/entrydsm/feed/infrastructure/grpc/client/dto/response/InternalAdminResponse.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package hs.kr.entrydsm.feed.infrastructure.grpc.client.dto.response | ||
|
|
||
| import java.util.UUID | ||
|
|
||
| /** | ||
| * ๊ด๋ฆฌ์ ์ ๋ณด๋ฅผ ๋ด๋ ๋ฐ์ดํฐ ํด๋์ค์ ๋๋ค. | ||
| * | ||
| * @property id ๊ด๋ฆฌ์์ ๊ณ ์ ์๋ณ์(UUID) | ||
| */ | ||
| data class InternalAdminResponse( | ||
| val id: UUID | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| syntax = "proto3"; | ||
|
|
||
| package casper.feed; | ||
coehgns marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| option java_package = "hs.kr.entrydsm.casper.admin.proto"; | ||
| option java_outer_classname = "AdminServiceProto"; | ||
|
|
||
| service AdminService { | ||
| rpc GetAdminByUUID(GetAdminIdRequest) returns (GetAdminIdResponse); | ||
| } | ||
|
|
||
| message GetAdminIdRequest { | ||
| string admin_id =1; | ||
| } | ||
|
|
||
| message GetAdminIdResponse{ | ||
| string admin_id = 1; | ||
| } | ||
coehgns marked this conversation as resolved.
Show resolved
Hide resolved
|
||
26 changes: 26 additions & 0 deletions
26
casper-feed/src/test/kotlin/hs/kr/entrydsm/feed/CasperFeedApplicationTests.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package hs.kr.entrydsm.feed | ||
|
|
||
| import org.junit.jupiter.api.Test | ||
| import org.springframework.boot.test.context.SpringBootTest | ||
|
|
||
| /** | ||
| * Casper Feed ์ ํ๋ฆฌ์ผ์ด์ ์ ํตํฉ ํ ์คํธ ํด๋์ค์ ๋๋ค. | ||
| * | ||
| * ์ด ํด๋์ค๋ Spring ์ ํ๋ฆฌ์ผ์ด์ ์ปจํ ์คํธ๊ฐ ๋ชจ๋ ํ์ํ ๋น๊ณผ ์ค์ ๊ณผ ํจ๊ป | ||
| * ์ฑ๊ณต์ ์ผ๋ก ๋ก๋๋๋์ง ๊ฒ์ฆํฉ๋๋ค. | ||
| */ | ||
| @SpringBootTest(classes = [CasperFeedApplication::class]) | ||
| class CasperFeedApplicationTests { | ||
|
|
||
| /** | ||
| * ์ ํ๋ฆฌ์ผ์ด์ ์ปจํ ์คํธ๊ฐ ์ฑ๊ณต์ ์ผ๋ก ๋ก๋๋๋์ง ํ ์คํธํฉ๋๋ค. | ||
| * | ||
| * ์ด ํ ์คํธ๋ Spring ์ ํ๋ฆฌ์ผ์ด์ ์ปจํ ์คํธ๊ฐ ๋ชจ๋ ํ์ํ ์ค์ ๊ณผ ๋น์ด ์ ๋๋ก | ||
| * ์ด๊ธฐํ๋ ์ํ๋ก ์์๋ ์ ์๋์ง ํ์ธํฉ๋๋ค. | ||
| * ์ปจํ ์คํธ ๋ก๋ฉ์ ์คํจํ ๊ฒฝ์ฐ ์ด ํ ์คํธ๋ ์คํจํฉ๋๋ค. | ||
| */ | ||
| @Test | ||
| fun contextLoads() { | ||
| // ์ ํ๋ฆฌ์ผ์ด์ ์ปจํ ์คํธ๊ฐ ์ฑ๊ณต์ ์ผ๋ก ๋ก๋๋๋ฉด ํ ์คํธ๊ฐ ํต๊ณผํฉ๋๋ค. | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.