๐ :: [#616] - RedisLimitAdapter ๋ฆฌํํ ๋ง#617
Conversation
WalkthroughRedis ํด๋ผ์ด์ธํธ์ ์์ฑ ๋ฐ ์ฃผ์ ๋ฐฉ์์ด ๋ณ๊ฒฝ๋์์ต๋๋ค. ๊ธฐ์กด์๋ RedisConfig์์ RedisClient ๋น์ ์ ๊ณตํ์ผ๋, ์ด์ RedisLimitAdapter๊ฐ RedisConnectionFactory๋ฅผ ๋ฐ์ ๋ด๋ถ์ ์ผ๋ก RedisClient๋ฅผ ์์ฑํฉ๋๋ค. ๋ํ, RedisLimitAdapter์ ๋ํ ๋จ์ ํ ์คํธ๊ฐ ์๋ก ์ถ๊ฐ๋์์ต๋๋ค. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant RedisLimitAdapter
participant RedisConnectionFactory
participant RedisClient
participant Redis
Client->>RedisLimitAdapter: ์์ฑ์ ํธ์ถ (RedisConnectionFactory ์ฃผ์
)
RedisLimitAdapter->>RedisConnectionFactory: host/port ์ ๋ณด ์ถ์ถ
RedisLimitAdapter->>RedisClient: RedisClient ์์ฑ
RedisLimitAdapter->>Redis: Bucket4j ProxyManager ์ด๊ธฐํ
Client->>RedisLimitAdapter: consumer/resolveToken ๋ฉ์๋ ํธ์ถ
RedisLimitAdapter->>Redis: ํ ํฐ ์๋น ๋ฐ ์ ํ ์ฒดํฌ
Possibly related PRs
Suggested labels
Poem
โจ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. ๐ชง TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 5
๐งน Nitpick comments (4)
src/test/kotlin/com/dcd/server/infrastructure/global/thirdparty/bucket4j/RedisLimitAdapterTest.kt (2)
13-15: ํ ์คํธ ํด๋์ค ์์กด์ฑ ์ฃผ์ ๋ฐฉ์ ๊ฒํ ํ์์์ฑ์ ์ฃผ์ ์ ํตํด
RedisLimitAdapter๋ฅผ ๋ฐ๊ณ ์๋๋ฐ, ํ ์คํธ ๊ฒฉ๋ฆฌ๋ฅผ ์ํด ๊ฐ ํ ์คํธ๋ง๋ค ๋ ๋ฆฝ์ ์ธ ์ธ์คํด์ค๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๊ณ ๋ คํด๋ณด์ธ์.
16-29: ํ ์คํธ ์ปค๋ฒ๋ฆฌ์ง๋ฅผ ๊ฐ์ ํ์ธ์.ํ์ฌ ํ ์คํธ๋ ์ฉ๋ ์ด๊ณผ ์ false ๋ฐํ๋ง ๊ฒ์ฆํ๊ณ ์์ต๋๋ค. ๋ค์๊ณผ ๊ฐ์ ์ถ๊ฐ ํ ์คํธ ์ผ์ด์ค๋ฅผ ๊ณ ๋ คํด๋ณด์ธ์:
- ์ฉ๋ ๋ด์์ ํ ํฐ ์๋น ์ true ๋ฐํ ๊ฒ์ฆ
- ์๊ฐ ๊ฒฝ๊ณผ ํ ํ ํฐ ์ฌ์ถฉ์ ๊ฒ์ฆ
- ๋ค๋ฅธ ํค์ ๋ํ ๋ ๋ฆฝ์ ์ธ ํ ํฐ ๊ด๋ฆฌ ๊ฒ์ฆ
given("ํ ์คํธํ Limit ์ด๋ ธํ ์ด์ ์ด ์ฃผ์ด์ง๊ณ ") { val targetLimitAnnotation = Limit(target = "test") + `when`("์ฉ๋ ๋ด์์ ํ ํฐ์ ์๋นํ ๋") { + then("๋ฐํ๊ฐ์ด true์ฌ์ผํจ") { + redisLimitAdapter.consumer(targetLimitAnnotation.target, targetLimitAnnotation) shouldBe true + } + } `when`("์ด๋ ธํ ์ด์ ์ ์ค์ ๋ ํ์ ์ด๊ณผ๋ก ํ ํฐ์ ์๋นํ ๋") { val capacity = targetLimitAnnotation.capacity for (i in 0 until capacity) { redisLimitAdapter.consumer(targetLimitAnnotation.target, targetLimitAnnotation) } then("๋ฐํ๊ฐ์ด false์ฌ์ผํจ") { redisLimitAdapter.consumer(targetLimitAnnotation.target, targetLimitAnnotation) shouldBe false } } }src/main/kotlin/com/dcd/server/infrastructure/global/thirdparty/bucket4j/RedisLimitAdapter.kt (2)
21-21: ์์ฑ์ ํ๋ผ๋ฏธํฐ ๋ช ๋ช ๊ฐ์ํ๋ผ๋ฏธํฐ๋ช ์ด ์ง์ญ ๋ณ์๋ก๋ง ์ฌ์ฉ๋๋ฏ๋ก ๋ ๋ช ํํ ์ด๋ฆ์ ์ฌ์ฉํ๋ ๊ฒ์ ๊ณ ๋ คํด๋ณด์ธ์.
- redisConnectionFactory: RedisConnectionFactory + private val redisConnectionFactory: RedisConnectionFactory
31-31: ์ฐ๊ฒฐ ๋ฌธ์์ด ๋ณด์ ๊ฐํํ๋์ฝ๋ฉ๋ Redis URI ์คํค๋ง ๋์ ๋ณด๋ค ์์ ํ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋ ๊ฒ์ ๊ณ ๋ คํด๋ณด์ธ์. ํนํ ํ๋ก๋์ ํ๊ฒฝ์์ ์ธ์ฆ์ด ํ์ํ ๊ฒฝ์ฐ๋ฅผ ๋๋นํด์ผ ํฉ๋๋ค.
๋ ์ ์ฐํ URI ์์ฑ ๋ฐฉ์:
val redisUri = if (connectionFactory.password != null) { "redis://:${connectionFactory.password}@$hostName:$port" } else { "redis://$hostName:$port" } val redisClient = RedisClient.create(redisUri)
๐ Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
๐ Files selected for processing (3)
src/main/kotlin/com/dcd/server/infrastructure/global/config/RedisConfig.kt(0 hunks)src/main/kotlin/com/dcd/server/infrastructure/global/thirdparty/bucket4j/RedisLimitAdapter.kt(1 hunks)src/test/kotlin/com/dcd/server/infrastructure/global/thirdparty/bucket4j/RedisLimitAdapterTest.kt(1 hunks)
๐ค Files with no reviewable changes (1)
- src/main/kotlin/com/dcd/server/infrastructure/global/config/RedisConfig.kt
โฐ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Build and Test
๐ Additional comments (1)
src/main/kotlin/com/dcd/server/infrastructure/global/thirdparty/bucket4j/RedisLimitAdapter.kt (1)
21-21: ์์กด์ฑ ์ฃผ์ ๊ฐ์ ์ ์น์ธํฉ๋๋ค.RedisConnectionFactory๋ฅผ ํตํ ์์กด์ฑ ์ฃผ์ ์ผ๋ก ๋ณ๊ฒฝํ ๊ฒ์ ์ข์ ๊ฐ์ ์ ๋๋ค. ์ด๋ ๋ ์ ์ฐํ Redis ์ฐ๊ฒฐ ์ค์ ์ ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค.
๊ฐ์
์์ ๋ด์ฉ
์ฒดํฌ๋ฆฌ์คํธ
Summary by CodeRabbit
๋ฆฌํฉํฐ๋ง
ํ ์คํธ