Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 스케줄러 구성을 개선합니다. #465

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ private excludedClassFilesForReport(classDirectories) {
"**/*Request*",
"**/exception/**",
"**/Mock**",
"**/aspect/**"
"**/aspect/**",
"**/scheduler/**"
])
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableScheduling
@SpringBootApplication
public class AnifriendsApplication {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class Recruitment extends BaseTimeEntity {
@Column(name = "updated_at")
private LocalDateTime updatedAt;

@Embedded
private RecruitmentApplicantCount applicantCount = new RecruitmentApplicantCount(0);

public Recruitment(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.clova.anifriends.global.config;

import com.clova.anifriends.domain.notification.service.ShelterNotificationService;
import com.clova.anifriends.domain.notification.service.VolunteerNotificationService;
import com.clova.anifriends.domain.recruitment.service.RecruitmentService;
import com.clova.anifriends.global.scheduler.NotifyScheduler;
import com.clova.anifriends.global.scheduler.ServiceScheduler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

@ConditionalOnProperty(
value = "scheduler.enabled", havingValue = "true", matchIfMissing = true
)
@EnableScheduling
@Configuration
public class SchedulerConfig {

@Bean
public NotifyScheduler notifyScheduler(
VolunteerNotificationService volunteerNotificationService,
ShelterNotificationService shelterNotificationService
) {
return new NotifyScheduler(volunteerNotificationService, shelterNotificationService);
}

@Bean
public ServiceScheduler serviceScheduler(RecruitmentService recruitmentService) {
return new ServiceScheduler(recruitmentService);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import com.clova.anifriends.domain.notification.service.VolunteerNotificationService;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class NotifyScheduler {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import com.clova.anifriends.domain.recruitment.service.RecruitmentService;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class ServiceScheduler {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
import com.clova.anifriends.base.TestContainerStarter;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

@SpringBootTest
@ActiveProfiles("dev")
class AnifriendsApplicationTests extends TestContainerStarter {

@Test
void contextLoads() {
}

}
43 changes: 0 additions & 43 deletions src/test/java/com/clova/anifriends/base/BaseSchedulerTest.java

This file was deleted.

This file was deleted.

This file was deleted.

6 changes: 5 additions & 1 deletion src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ jwt:
secret: ThisIsJustTestSecretSoDontWorryItsOnlyForTest
refresh-expiry-seconds: 100000
refresh-secret: ThisIsJustTestRefreshSecretSoDontWorryItsOnlyForTest

scheduler:
enabled: false

spring:
datasource:
driver-class-name: org.h2.Driver
username: sa
url: jdbc:h2:mem:testdb
url: jdbc:h2:mem:testdb;MODE=MYSQL;
jpa:
properties:
hibernate:
Expand Down
Loading