package com.dog.dognation.scheduler; import com.dog.dognation.domain.matching.MatchingService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** * 매칭 신청 20분 자동 종료 스케줄러. * 1분마다 대기중(PENDING)인데 만료시각이 지난 신청을 EXPIRED 로 처리하고 신청자에게 알린다. */ @Component public class MatchExpiryScheduler { private static final Logger log = LoggerFactory.getLogger(MatchExpiryScheduler.class); private final MatchingService matchingService; public MatchExpiryScheduler(MatchingService matchingService) { this.matchingService = matchingService; } @Scheduled(fixedRate = 60_000) public void expireOverdueMatches() { try { int n = matchingService.expireOverdue(); if (n > 0) { log.info("[매칭 만료] 20분 미수락 {}건 자동 종료", n); } } catch (Exception e) { log.warn("[매칭 만료] 처리 실패: {}", e.toString()); } } }