Skip to content

Commit

Permalink
feat: 낙관적락 retry 로직이 빠진부분에 retry로직을 추가한다
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb committed May 11, 2024
1 parent 3f209dc commit 1e552a1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/kotlin/org/gitanimals/render/domain/UserService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class UserService(
fun createNewUser(name: String, contributions: Map<Int, Int>): User =
userRepository.save(User.newUser(name, contributions))

@Retryable(retryFor = [ObjectOptimisticLockingFailureException::class], maxAttempts = 100)
@Transactional
fun giveBonusPersona(id: Long, persona: String) {
requireIdempotency("$id:bonus")
Expand All @@ -58,6 +59,7 @@ class UserService(
user.giveBonusPersona(persona)
}

@Retryable(retryFor = [ObjectOptimisticLockingFailureException::class], maxAttempts = 100)
@Transactional
fun changePersona(id: Long, personChangeRequest: PersonaChangeRequest) {
val user = getUserById(id)
Expand Down

0 comments on commit 1e552a1

Please sign in to comment.