Projection was now built on listener events

Create ProjectionBus and use it with listeners
add EventStream::getByVersion
This commit is contained in:
2025-03-18 21:48:37 +01:00
parent 908cc888ad
commit 8c1eabb9f5
22 changed files with 126 additions and 89 deletions

View File

@@ -1,10 +1,10 @@
package eventDemo.configuration.business
import eventDemo.business.event.eventListener.ReactionEventListener
import eventDemo.business.event.projection.projectionListener.ReactionListener
import io.ktor.server.application.Application
import org.koin.ktor.ext.get
fun Application.configureGameListener() {
ReactionEventListener(get(), get(), get())
ReactionListener(get(), get())
.init()
}

View File

@@ -3,7 +3,7 @@ package eventDemo.configuration.injection
import eventDemo.business.command.GameCommandActionRunner
import eventDemo.business.command.GameCommandHandler
import eventDemo.business.event.GameEventHandler
import eventDemo.business.event.eventListener.PlayerNotificationEventListener
import eventDemo.business.event.projection.projectionListener.PlayerNotificationListener
import org.koin.core.module.Module
import org.koin.core.module.dsl.singleOf
@@ -13,5 +13,5 @@ fun Module.configureDIBusiness() {
}
singleOf(::GameEventHandler)
singleOf(::GameCommandActionRunner)
singleOf(::PlayerNotificationEventListener)
singleOf(::PlayerNotificationListener)
}

View File

@@ -3,29 +3,28 @@ package eventDemo.configuration.injection
import eventDemo.adapter.infrastructureLayer.event.GameEventBusInMemory
import eventDemo.adapter.infrastructureLayer.event.GameEventStoreInMemory
import eventDemo.adapter.infrastructureLayer.event.projection.GameListRepositoryInMemory
import eventDemo.adapter.infrastructureLayer.event.projection.GameProjectionBusInMemory
import eventDemo.adapter.infrastructureLayer.event.projection.GameStateRepositoryInMemory
import eventDemo.business.event.GameEventBus
import eventDemo.business.event.GameEventStore
import eventDemo.business.event.projection.GameProjectionBus
import eventDemo.business.event.projection.gameList.GameListRepository
import eventDemo.business.event.projection.gameState.GameStateRepository
import eventDemo.libs.event.projection.SnapshotConfig
import org.koin.core.module.Module
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.bind
fun Module.configureDIInfrastructure() {
single {
GameEventBusInMemory()
} bind GameEventBus::class
singleOf(::GameEventBusInMemory) bind GameEventBus::class
singleOf(::GameEventStoreInMemory) bind GameEventStore::class
singleOf(::GameProjectionBusInMemory) bind GameProjectionBus::class
single {
GameEventStoreInMemory()
} bind GameEventStore::class
single {
GameStateRepositoryInMemory(get(), get(), snapshotConfig = SnapshotConfig())
GameStateRepositoryInMemory(get(), get(), get(), snapshotConfig = SnapshotConfig())
} bind GameStateRepository::class
single {
GameListRepositoryInMemory(get(), get(), snapshotConfig = SnapshotConfig())
GameListRepositoryInMemory(get(), get(), get(), snapshotConfig = SnapshotConfig())
} bind GameListRepository::class
}

View File

@@ -2,14 +2,14 @@ package eventDemo.configuration.route
import eventDemo.adapter.interfaceLayer.gameWebSocket
import eventDemo.business.command.GameCommandHandler
import eventDemo.business.event.eventListener.PlayerNotificationEventListener
import eventDemo.business.event.projection.projectionListener.PlayerNotificationListener
import io.ktor.server.application.Application
import io.ktor.server.routing.routing
import kotlinx.coroutines.DelicateCoroutinesApi
@OptIn(DelicateCoroutinesApi::class)
fun Application.declareWebSocketsGameRoute(
playerNotificationListener: PlayerNotificationEventListener,
playerNotificationListener: PlayerNotificationListener,
commandHandler: GameCommandHandler,
) {
routing {