Skip to content

Commit

Permalink
ratelimit 걸리지 않아서 걸리도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhvictor4 committed Sep 10, 2023
1 parent 9cabb5d commit 3745634
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions batch/src/main/kotlin/timetables/job/AutoPrimaryJobConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.wafflestudio.snu4t.timetables.job

import com.wafflestudio.snu4t.common.enum.Semester
import com.wafflestudio.snu4t.timetables.repository.TimetableRepository
import io.github.resilience4j.kotlin.ratelimiter.executeSuspendFunction
import io.github.resilience4j.kotlin.ratelimiter.rateLimiter
import io.github.resilience4j.ratelimiter.RateLimiter
import io.github.resilience4j.ratelimiter.RateLimiterConfig
Expand Down Expand Up @@ -59,9 +60,7 @@ class AutoPrimaryJobConfig(
val agg = Aggregation.newAggregation(Key::class.java, Aggregation.group("user_id", "semester", "year"))
reactiveMongoTemplate.aggregate(agg, "timetables", AggResult::class.java)
.asFlow()
.map { autoSetPrimary(it.id) }
.rateLimiter(rateLimiter)
.collect { }
.collect { rateLimiter.executeSuspendFunction { autoSetPrimary(it.id) } }
}

private suspend fun autoSetPrimary(key: Key) {
Expand Down

0 comments on commit 3745634

Please sign in to comment.