Skip to content
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

DRAW-416 빠른 매칭 유저 중복 등록 오류 수정 #18

Merged
merged 4 commits into from
Nov 25, 2024

Conversation

SunwoongH
Copy link
Contributor

Related Jira ✔

Description ✔

PR Rule ✔

P1: 꼭 반영해주세요 (Request changes)
P2: 적극적으로 고려해주세요 (Request changes)
P3: 웬만하면 반영해 주세요 (Comment)
P4: 반영해도 좋고 넘어가도 좋습니다 (Approve)
P5: 그냥 사소한 의견입니다 (Approve)

@SunwoongH SunwoongH requested a review from comforest November 11, 2024 06:55
@SunwoongH SunwoongH self-assigned this Nov 11, 2024
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentLinkedQueue
import org.springframework.stereotype.Component

@Component
internal class MafiaGameWaitingQueueAdapter : MafiaGameWaitingQueueRepository {
private val waitingQueue: ConcurrentHashMap<String, ConcurrentLinkedQueue<User>> = ConcurrentHashMap()
private val seen: ConcurrentHashMap<String, MutableSet<UserId>> = ConcurrentHashMap()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p3. 대기열 개수가 많지 않고 (일정 수치가 되면 비워지는 로직이기에)
자주 조회하는 로직도 아니기에
굳이 set을 또 만들지 않고 전체 탐색해도 괜찮을 것 같습니다.


override fun size(locale: String): Int {
return waitingQueue[locale]?.size ?: 0
}

override fun enqueue(user: User, locale: String) {
val queue = waitingQueue.getOrPut(locale) { ConcurrentLinkedQueue() }
val seen = seen.getOrPut(locale) { ConcurrentHashMap.newKeySet() }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p3. 위 코멘트와 별개로 전역변수 이름과 지역 변수 이름은 다르게 가면 좋을 것 같습니다.

IDE에선 읽을 때 색이 표시되는데 Github에서는 차이가 안나요 ㅠ

# Conflicts:
#	domain/src/main/kotlin/com/xorker/draw/exception/XorkerException.kt
@SunwoongH SunwoongH requested a review from comforest November 13, 2024 11:53
Base automatically changed from feature/DRAW-412 to feature/DRAW-347 November 25, 2024 11:19
@comforest comforest merged commit 8677787 into feature/DRAW-347 Nov 25, 2024
1 check passed
@comforest comforest deleted the feature/DRAW-416 branch November 25, 2024 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants