05. Moments - a Passage of Time Events API
spring-modulith-moments
- 시간 흐름의 이벤트를 구현
- 특정 시간 경과와 관련된 작업을 트리거 하는 이벤트 기반 시간 접근 방식
spring-modulith-moments
종속성을 추가하면 아래 일이 발생한다.
- 애플리케이션은
HourHasPassed
, DayHasPassed
, WeekHasPassed
, MonthHasPassed
, QuarterHasPassed
, YearHasPassed
타입의 이벤트를 통해 특정 시간이 경과하면 알림을 받을 수 있다.
org.springframework.modulith.Moments
타입의 빈을 사용 가능
spring.modulith.moments.enable-time-machiine
을 true
로 설정하면 org.springframework.modulith.TimeMachine
인스턴스를 통해 시간을 이동시킬 수 있으며 이로 인해 중간 이벤트가 모두 트리거 된다.
- 기본적으로
Moments
는 Clock.systemUTC()
인스턴스를 사용한다.
- 이를 커스터마이징하려먼
Clock
을 빈으로 등록하면 된다.