Skip to content

Commit 7bdcac5

Browse files
committed
feat: 콜드 스타트 스케줄러 구현
1 parent 011682b commit 7bdcac5

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.loopers.infrastructure.ranking;
2+
3+
import com.loopers.ranking.RankingService;
4+
import java.time.LocalDate;
5+
import java.time.ZoneId;
6+
import lombok.RequiredArgsConstructor;
7+
import lombok.extern.slf4j.Slf4j;
8+
import org.springframework.scheduling.annotation.Scheduled;
9+
import org.springframework.stereotype.Component;
10+
11+
@Slf4j
12+
@Component
13+
@RequiredArgsConstructor
14+
public class RankingCarryOverScheduler {
15+
16+
private static final ZoneId ZONE_ID = ZoneId.of("Asia/Seoul");
17+
private static final double CARRY_OVER_WEIGHT = 0.5d;
18+
19+
private final RankingService rankingService;
20+
21+
@Scheduled(cron = "0 50 23 * * *", zone = "Asia/Seoul")
22+
public void carryOverForTomorrow() {
23+
LocalDate tomorrow = LocalDate.now(ZONE_ID).plusDays(1);
24+
try {
25+
rankingService.carryOver(tomorrow, CARRY_OVER_WEIGHT);
26+
log.info("Ranking carry-over completed for date={} weight={}", tomorrow, CARRY_OVER_WEIGHT);
27+
} catch (Exception exception) {
28+
log.error("Ranking carry-over failed for date={}", tomorrow, exception);
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)