-
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 #66 from uju-in/LIME-131-process-vote-redis-logic-…
…asynchronously-with-event
- Loading branch information
Showing
10 changed files
with
101 additions
and
112 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
9 changes: 9 additions & 0 deletions
9
lime-api/src/main/java/com/programmers/lime/global/event/ranking/vote/RankingAddEvent.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,9 @@ | ||
package com.programmers.lime.global.event.ranking.vote; | ||
|
||
import com.programmers.lime.redis.vote.VoteRankingInfo; | ||
|
||
public record RankingAddEvent( | ||
String hobby, | ||
VoteRankingInfo voteRankingInfo | ||
) { | ||
} |
9 changes: 9 additions & 0 deletions
9
...n/java/com/programmers/lime/global/event/ranking/vote/RankingDecreasePopularityEvent.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,9 @@ | ||
package com.programmers.lime.global.event.ranking.vote; | ||
|
||
import com.programmers.lime.redis.vote.VoteRankingInfo; | ||
|
||
public record RankingDecreasePopularityEvent( | ||
String hobby, | ||
VoteRankingInfo voteRankingInfo | ||
) { | ||
} |
9 changes: 9 additions & 0 deletions
9
...-api/src/main/java/com/programmers/lime/global/event/ranking/vote/RankingDeleteEvent.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,9 @@ | ||
package com.programmers.lime.global.event.ranking.vote; | ||
|
||
import com.programmers.lime.redis.vote.VoteRankingInfo; | ||
|
||
public record RankingDeleteEvent( | ||
String hobby, | ||
VoteRankingInfo voteRankingInfo | ||
) { | ||
} |
40 changes: 40 additions & 0 deletions
40
...pi/src/main/java/com/programmers/lime/global/event/ranking/vote/RankingEventListener.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,40 @@ | ||
package com.programmers.lime.global.event.ranking.vote; | ||
|
||
import org.springframework.context.event.EventListener; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.programmers.lime.redis.vote.VoteRedisManager; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class RankingEventListener { | ||
|
||
private final VoteRedisManager voteRedisManager; | ||
|
||
@Async | ||
@EventListener | ||
public void addRanking(final RankingAddEvent event) { | ||
voteRedisManager.addRanking(event.hobby(), event.voteRankingInfo()); | ||
} | ||
|
||
@Async | ||
@EventListener | ||
public void updateRanking(final RankingUpdateEvent event) { | ||
voteRedisManager.updateRanking(event.hobby(), event.isVoting(), event.voteRankingInfo()); | ||
} | ||
|
||
@Async | ||
@EventListener | ||
public void decreasePopularity(final RankingDecreasePopularityEvent event) { | ||
voteRedisManager.updatePopularity(event.hobby(), event.voteRankingInfo(), -1); | ||
} | ||
|
||
@Async | ||
@EventListener | ||
public void deleteRanking(final RankingDeleteEvent event) { | ||
voteRedisManager.deleteRanking(event.hobby(), event.voteRankingInfo()); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...-api/src/main/java/com/programmers/lime/global/event/ranking/vote/RankingUpdateEvent.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,10 @@ | ||
package com.programmers.lime.global.event.ranking.vote; | ||
|
||
import com.programmers.lime.redis.vote.VoteRankingInfo; | ||
|
||
public record RankingUpdateEvent( | ||
String hobby, | ||
boolean isVoting, | ||
VoteRankingInfo voteRankingInfo | ||
) { | ||
} |
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
Oops, something went wrong.