From a2756d7fdb27794e18a0a9de287c821057809c71 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Tue, 11 Mar 2025 21:49:29 +0100 Subject: [PATCH] Rename listeners --- src/main/kotlin/eventDemo/app/command/GameCommandRoute.kt | 4 ++-- ...tionListener.kt => PlayerNotificationEventListener.kt} | 2 +- ...eEventReactionListener.kt => ReactionEventListener.kt} | 2 +- src/main/kotlin/eventDemo/configuration/ConfigureDI.kt | 4 ++-- .../eventDemo/configuration/ConfigureGameListener.kt | 4 ++-- .../configuration/ConfigureWebSocketsGameRoute.kt | 4 ++-- .../eventDemo/app/command/GameCommandHandlerTest.kt | 8 ++++---- src/test/kotlin/eventDemo/app/query/GameStateTest.kt | 8 ++++---- 8 files changed, 18 insertions(+), 18 deletions(-) rename src/main/kotlin/eventDemo/app/eventListener/{GameEventPlayerNotificationListener.kt => PlayerNotificationEventListener.kt} (99%) rename src/main/kotlin/eventDemo/app/eventListener/{GameEventReactionListener.kt => ReactionEventListener.kt} (98%) diff --git a/src/main/kotlin/eventDemo/app/command/GameCommandRoute.kt b/src/main/kotlin/eventDemo/app/command/GameCommandRoute.kt index ffe11ab..b46b6ff 100644 --- a/src/main/kotlin/eventDemo/app/command/GameCommandRoute.kt +++ b/src/main/kotlin/eventDemo/app/command/GameCommandRoute.kt @@ -1,7 +1,7 @@ package eventDemo.app.command import eventDemo.app.entity.Player -import eventDemo.app.eventListener.GameEventPlayerNotificationListener +import eventDemo.app.eventListener.PlayerNotificationEventListener import eventDemo.app.notification.Notification import eventDemo.libs.fromFrameChannel import eventDemo.libs.toObjectChannel @@ -18,7 +18,7 @@ import kotlinx.coroutines.launch @DelicateCoroutinesApi fun Route.gameSocket( - playerNotificationListener: GameEventPlayerNotificationListener, + playerNotificationListener: PlayerNotificationEventListener, commandHandler: GameCommandHandler, ) { authenticate { diff --git a/src/main/kotlin/eventDemo/app/eventListener/GameEventPlayerNotificationListener.kt b/src/main/kotlin/eventDemo/app/eventListener/PlayerNotificationEventListener.kt similarity index 99% rename from src/main/kotlin/eventDemo/app/eventListener/GameEventPlayerNotificationListener.kt rename to src/main/kotlin/eventDemo/app/eventListener/PlayerNotificationEventListener.kt index 0dba1f4..14b8cb1 100644 --- a/src/main/kotlin/eventDemo/app/eventListener/GameEventPlayerNotificationListener.kt +++ b/src/main/kotlin/eventDemo/app/eventListener/PlayerNotificationEventListener.kt @@ -27,7 +27,7 @@ import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.coroutines.channels.SendChannel import kotlinx.coroutines.channels.trySendBlocking -class GameEventPlayerNotificationListener( +class PlayerNotificationEventListener( private val eventBus: GameEventBus, private val gameStateRepository: GameStateRepository, ) { diff --git a/src/main/kotlin/eventDemo/app/eventListener/GameEventReactionListener.kt b/src/main/kotlin/eventDemo/app/eventListener/ReactionEventListener.kt similarity index 98% rename from src/main/kotlin/eventDemo/app/eventListener/GameEventReactionListener.kt rename to src/main/kotlin/eventDemo/app/eventListener/ReactionEventListener.kt index 9443dbe..07ef376 100644 --- a/src/main/kotlin/eventDemo/app/eventListener/GameEventReactionListener.kt +++ b/src/main/kotlin/eventDemo/app/eventListener/ReactionEventListener.kt @@ -10,7 +10,7 @@ import eventDemo.app.event.projection.GameState import eventDemo.app.event.projection.GameStateRepository import io.github.oshai.kotlinlogging.KotlinLogging -class GameEventReactionListener( +class ReactionEventListener( private val eventBus: GameEventBus, private val eventHandler: GameEventHandler, private val gameStateRepository: GameStateRepository, diff --git a/src/main/kotlin/eventDemo/configuration/ConfigureDI.kt b/src/main/kotlin/eventDemo/configuration/ConfigureDI.kt index 117780f..e388d26 100644 --- a/src/main/kotlin/eventDemo/configuration/ConfigureDI.kt +++ b/src/main/kotlin/eventDemo/configuration/ConfigureDI.kt @@ -6,7 +6,7 @@ import eventDemo.app.event.GameEventBus import eventDemo.app.event.GameEventHandler import eventDemo.app.event.GameEventStream import eventDemo.app.event.projection.GameStateRepository -import eventDemo.app.eventListener.GameEventPlayerNotificationListener +import eventDemo.app.eventListener.PlayerNotificationEventListener import eventDemo.libs.command.CommandStreamChannelBuilder import eventDemo.libs.event.EventBusInMemory import eventDemo.libs.event.EventStreamInMemory @@ -41,5 +41,5 @@ val appKoinModule = singleOf(::GameEventHandler) singleOf(::GameCommandHandler) - singleOf(::GameEventPlayerNotificationListener) + singleOf(::PlayerNotificationEventListener) } diff --git a/src/main/kotlin/eventDemo/configuration/ConfigureGameListener.kt b/src/main/kotlin/eventDemo/configuration/ConfigureGameListener.kt index 2baa81c..27f4889 100644 --- a/src/main/kotlin/eventDemo/configuration/ConfigureGameListener.kt +++ b/src/main/kotlin/eventDemo/configuration/ConfigureGameListener.kt @@ -1,10 +1,10 @@ package eventDemo.configuration -import eventDemo.app.eventListener.GameEventReactionListener +import eventDemo.app.eventListener.ReactionEventListener import io.ktor.server.application.Application import org.koin.ktor.ext.get fun Application.configureGameListener() { - GameEventReactionListener(get(), get(), get()) + ReactionEventListener(get(), get(), get()) .init() } diff --git a/src/main/kotlin/eventDemo/configuration/ConfigureWebSocketsGameRoute.kt b/src/main/kotlin/eventDemo/configuration/ConfigureWebSocketsGameRoute.kt index 2301b4f..16c973e 100644 --- a/src/main/kotlin/eventDemo/configuration/ConfigureWebSocketsGameRoute.kt +++ b/src/main/kotlin/eventDemo/configuration/ConfigureWebSocketsGameRoute.kt @@ -2,14 +2,14 @@ package eventDemo.configuration import eventDemo.app.command.GameCommandHandler import eventDemo.app.command.gameSocket -import eventDemo.app.eventListener.GameEventPlayerNotificationListener +import eventDemo.app.eventListener.PlayerNotificationEventListener import io.ktor.server.application.Application import io.ktor.server.routing.routing import kotlinx.coroutines.DelicateCoroutinesApi @OptIn(DelicateCoroutinesApi::class) fun Application.declareWebSocketsGameRoute( - playerNotificationListener: GameEventPlayerNotificationListener, + playerNotificationListener: PlayerNotificationEventListener, commandHandler: GameCommandHandler, ) { routing { diff --git a/src/test/kotlin/eventDemo/app/command/GameCommandHandlerTest.kt b/src/test/kotlin/eventDemo/app/command/GameCommandHandlerTest.kt index d11274a..5283ede 100644 --- a/src/test/kotlin/eventDemo/app/command/GameCommandHandlerTest.kt +++ b/src/test/kotlin/eventDemo/app/command/GameCommandHandlerTest.kt @@ -4,8 +4,8 @@ import eventDemo.app.command.command.GameCommand import eventDemo.app.command.command.IWantToJoinTheGameCommand import eventDemo.app.entity.GameId import eventDemo.app.entity.Player -import eventDemo.app.eventListener.GameEventPlayerNotificationListener -import eventDemo.app.eventListener.GameEventReactionListener +import eventDemo.app.eventListener.PlayerNotificationEventListener +import eventDemo.app.eventListener.ReactionEventListener import eventDemo.app.notification.Notification import eventDemo.app.notification.WelcomeToTheGameNotification import eventDemo.configuration.appKoinModule @@ -22,12 +22,12 @@ class GameCommandHandlerTest : test("handle a command should execute the command") { koinApplication { modules(appKoinModule) }.koin.apply { val commandHandler by inject() - val notificationListener by inject() + val notificationListener by inject() val gameId = GameId() val player = Player("Tesla") val channelCommand = Channel(Channel.BUFFERED) val channelNotification = Channel(Channel.BUFFERED) - GameEventReactionListener(get(), get(), get()).init() + ReactionEventListener(get(), get(), get()).init() notificationListener.startListening(channelNotification, player) GlobalScope.launch { diff --git a/src/test/kotlin/eventDemo/app/query/GameStateTest.kt b/src/test/kotlin/eventDemo/app/query/GameStateTest.kt index 49281b6..281d3a0 100644 --- a/src/test/kotlin/eventDemo/app/query/GameStateTest.kt +++ b/src/test/kotlin/eventDemo/app/query/GameStateTest.kt @@ -12,8 +12,8 @@ import eventDemo.app.event.GameEventStream import eventDemo.app.event.event.disableShuffleDeck import eventDemo.app.event.projection.GameState import eventDemo.app.event.projection.buildStateFromEventStream -import eventDemo.app.eventListener.GameEventPlayerNotificationListener -import eventDemo.app.eventListener.GameEventReactionListener +import eventDemo.app.eventListener.PlayerNotificationEventListener +import eventDemo.app.eventListener.ReactionEventListener import eventDemo.app.notification.ItsTheTurnOfNotification import eventDemo.app.notification.Notification import eventDemo.app.notification.PlayerAsJoinTheGameNotification @@ -131,8 +131,8 @@ class GameStateTest : koinApplication { modules(appKoinModule) }.koin.apply { val commandHandler by inject() val eventStream by inject() - val playerNotificationListener by inject() - GameEventReactionListener(get(), get(), get()).init() + val playerNotificationListener by inject() + ReactionEventListener(get(), get(), get()).init() playerNotificationListener.startListening(channelNotification1, player1) playerNotificationListener.startListening(channelNotification2, player2)