-
Notifications
You must be signed in to change notification settings - Fork 0
feat: aws EventBridge 추가 #52
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
765690e
feat/#51: aws sdk 의존성 추가
tkv00 6553bac
feat/#51: aws event publisher 기능 추가
tkv00 a4ada9a
chore/#51: aws event 변수 환경변수화
tkv00 4ec1dc9
fix/#51: aws EventBridge Test 환경에서 의존성 제거
tkv00 9176494
fix/#51: 응답 json dto 직렬화 변경
tkv00 83b4782
chore/#51: mongodb test container 의존성 추가
tkv00 cacd8ca
fix/#51: test 프로파일 예외 제거
tkv00 538e208
test/#51: mongo test container 환경 설정
tkv00 3a3de8c
remove/#51: applicationTest 삭제
tkv00 a63d92b
test/#51: UserSolvedSnapShotRepositoryTest MongoContainer 반영
tkv00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Empty file.
This file contains hidden or 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 hidden or 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 hidden or 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
14 changes: 14 additions & 0 deletions
14
src/main/java/store/slackjudge/batch/config/EventBridgeConfig.java
This file contains hidden or 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,14 @@ | ||
| package store.slackjudge.batch.config; | ||
|
|
||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.context.annotation.Profile; | ||
| import software.amazon.awssdk.services.eventbridge.EventBridgeClient; | ||
|
|
||
| @Configuration | ||
| public class EventBridgeConfig { | ||
| @Bean | ||
| public EventBridgeClient eventBridgeClient(){ | ||
| return EventBridgeClient.builder().build(); | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/store/slackjudge/batch/infra/aws/BatchEventDetail.java
This file contains hidden or 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,9 @@ | ||
| package store.slackjudge.batch.infra.aws; | ||
|
|
||
| import java.io.Serializable; | ||
|
|
||
| public record BatchEventDetail( | ||
| String jobId, | ||
| String status | ||
| ) implements Serializable { | ||
| } |
46 changes: 46 additions & 0 deletions
46
src/main/java/store/slackjudge/batch/infra/aws/EventBridgePublisher.java
This file contains hidden or 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,46 @@ | ||
| package store.slackjudge.batch.infra.aws; | ||
|
|
||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.context.annotation.Profile; | ||
| import org.springframework.stereotype.Service; | ||
| import software.amazon.awssdk.services.eventbridge.EventBridgeClient; | ||
| import software.amazon.awssdk.services.eventbridge.EventBridgeClientBuilder; | ||
| import software.amazon.awssdk.services.eventbridge.model.PutEventsRequest; | ||
| import software.amazon.awssdk.services.eventbridge.model.PutEventsRequestEntry; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class EventBridgePublisher { | ||
| private final EventBridgeClient bridgeClientBuilder; | ||
| private final ObjectMapper mapper; | ||
|
|
||
| @Value("${aws.eventbridge.source}") | ||
| private String source; | ||
|
|
||
| @Value("${aws.eventbridge.detail-type}") | ||
| private String detailType; | ||
|
|
||
| public void publishBatchSuccessCompleteEvent(String jobId, String status) { | ||
| try { | ||
| String detail = mapper.writeValueAsString(new BatchEventDetail(jobId, status)); | ||
| PutEventsRequestEntry eventsRequestEntry = PutEventsRequestEntry.builder() | ||
| .source(source) | ||
| .detailType(detailType) | ||
| .detail(detail) | ||
| .build(); | ||
|
|
||
| PutEventsRequest request = PutEventsRequest.builder() | ||
| .entries(eventsRequestEntry) | ||
| .build(); | ||
|
|
||
| bridgeClientBuilder.putEvents(request); | ||
| } catch (JsonProcessingException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } |
This file contains hidden or 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 hidden or 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,24 @@ | ||
| package store.slackjudge.batch; | ||
|
|
||
| import org.springframework.test.context.ActiveProfiles; | ||
| import org.springframework.test.context.DynamicPropertyRegistry; | ||
| import org.springframework.test.context.DynamicPropertySource; | ||
| import org.testcontainers.containers.MongoDBContainer; | ||
| import org.testcontainers.junit.jupiter.Container; | ||
| import org.testcontainers.junit.jupiter.Testcontainers; | ||
|
|
||
| @Testcontainers | ||
| @ActiveProfiles("test") | ||
| public class MongoContainer { | ||
| @Container | ||
| static final MongoDBContainer mongo=new MongoDBContainer("mongo:6.0") | ||
| .withReuse(true); | ||
|
|
||
| @DynamicPropertySource | ||
| static void mongoProperties(DynamicPropertyRegistry registry){ | ||
| registry.add( | ||
| "spring.data.mongodb.uri", | ||
| mongo::getReplicaSetUrl | ||
| ); | ||
| } | ||
| } |
15 changes: 0 additions & 15 deletions
15
src/test/java/store/slackjudge/batch/SlackjudgeApplicationTests.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -50,3 +50,8 @@ slack: | |
| logging: | ||
| level: | ||
| root: WARN | ||
|
|
||
| aws: | ||
| eventbridge: | ||
| enabled: false | ||
| region: ap-northeast-2 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.