-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
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() |
There was a problem hiding this comment.
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() } |
There was a problem hiding this comment.
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
Related Jira ✔
Description ✔
PR Rule ✔
P1: 꼭 반영해주세요 (Request changes)
P2: 적극적으로 고려해주세요 (Request changes)
P3: 웬만하면 반영해 주세요 (Comment)
P4: 반영해도 좋고 넘어가도 좋습니다 (Approve)
P5: 그냥 사소한 의견입니다 (Approve)