-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from Team-Going/feature/160
[refactor] 디스코드 웹훅 알림 비동기 이벤트로 리팩터링
- Loading branch information
Showing
17 changed files
with
126 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
doorip-common/src/main/java/org/doorip/event/SignUpEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.doorip.event; | ||
|
||
import org.doorip.message.EventMessage; | ||
|
||
public record SignUpEvent( | ||
EventMessage eventMessage, | ||
String name, | ||
int count | ||
) { | ||
public static SignUpEvent of(EventMessage eventMessage, String name, int count) { | ||
return new SignUpEvent(eventMessage, name, count); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
dependencies { | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
implementation project(path: ':doorip-common') | ||
} | ||
|
||
bootJar { | ||
enabled = false | ||
} | ||
|
||
jar { | ||
enabled = true | ||
} |
19 changes: 19 additions & 0 deletions
19
doorip-event-publisher/src/main/java/org/doorip/publisher/EventPublisher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.doorip.publisher; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.doorip.event.SignUpEvent; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
@Component | ||
public class EventPublisher { | ||
private final ApplicationEventPublisher eventPublisher; | ||
|
||
public void publishSignUpEvent(SignUpEvent event) { | ||
log.info("[publish] sign up event {}", event); | ||
eventPublisher.publishEvent(event); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
dependencies { | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
implementation project(path: ':doorip-common') | ||
implementation project(path: ':doorip-external') | ||
} | ||
|
||
bootJar { | ||
enabled = false | ||
} | ||
|
||
jar { | ||
enabled = true | ||
} |
23 changes: 23 additions & 0 deletions
23
doorip-event-subscriber/src/main/java/org/doorip/config/AsyncConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.doorip.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.EnableAsync; | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
|
||
import java.util.concurrent.Executor; | ||
|
||
@EnableAsync | ||
@Configuration | ||
public class AsyncConfig { | ||
@Bean | ||
public Executor threadPoolTaskExecutor() { | ||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | ||
executor.setCorePoolSize(3); | ||
executor.setMaxPoolSize(30); | ||
executor.setQueueCapacity(100); | ||
executor.setThreadNamePrefix("async-executor-"); | ||
executor.initialize(); | ||
return executor; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
doorip-event-subscriber/src/main/java/org/doorip/subscriber/EventSubscriber.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.doorip.subscriber; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.doorip.event.SignUpEvent; | ||
import org.doorip.message.EventMessage; | ||
import org.doorip.openfeign.discord.DiscordMessageProvider; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
@Component | ||
public class EventSubscriber { | ||
private final DiscordMessageProvider discordMessageProvider; | ||
|
||
@Async | ||
@EventListener | ||
public void subscribeSignUpEvent(SignUpEvent event) { | ||
log.info("[subscribe] sign up event {}", event); | ||
EventMessage eventMessage = event.eventMessage(); | ||
String message = String.format(eventMessage.getMessage(), event.name(), event.count()); | ||
discordMessageProvider.sendMessage(message); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
3 changes: 1 addition & 2 deletions
3
doorip-external/src/main/java/org/doorip/config/FeignClientConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
package org.doorip.config; | ||
|
||
import org.doorip.ExternalRoot; | ||
import org.springframework.cloud.openfeign.EnableFeignClients; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@EnableFeignClients(basePackageClasses = ExternalRoot.class) | ||
@EnableFeignClients(basePackages = "org.doorip") | ||
public class FeignClientConfig { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters