diff --git a/src/main/kotlin/eventDemo/configuration/business/ConfigureGameListener.kt b/src/main/kotlin/eventDemo/configuration/business/ConfigureGameListener.kt index 50816ca..0e076ad 100644 --- a/src/main/kotlin/eventDemo/configuration/business/ConfigureGameListener.kt +++ b/src/main/kotlin/eventDemo/configuration/business/ConfigureGameListener.kt @@ -1,7 +1,7 @@ package eventDemo.configuration.business -import eventDemo.adapter.infrastructureLayer.event.projection.GameListRepositoryInMemory -import eventDemo.adapter.infrastructureLayer.event.projection.GameStateRepositoryInMemory +import eventDemo.adapter.infrastructureLayer.event.projection.GameListRepositoryInRedis +import eventDemo.adapter.infrastructureLayer.event.projection.GameStateRepositoryInRedis import eventDemo.business.command.GameCommandHandler import eventDemo.business.event.projection.projectionListener.ReactionListener import org.koin.core.Koin @@ -10,10 +10,10 @@ fun Koin.configureGameListener() { get() .subscribeToBus(get()) - get() + get() .subscribeToBus(get(), get()) - get() + get() .subscribeToBus(get(), get()) get() diff --git a/src/main/kotlin/eventDemo/configuration/injection/ConfigureDIInfrastructure.kt b/src/main/kotlin/eventDemo/configuration/injection/ConfigureDIInfrastructure.kt index d23f0b9..d96900a 100644 --- a/src/main/kotlin/eventDemo/configuration/injection/ConfigureDIInfrastructure.kt +++ b/src/main/kotlin/eventDemo/configuration/injection/ConfigureDIInfrastructure.kt @@ -5,9 +5,9 @@ import com.zaxxer.hikari.HikariConfig import com.zaxxer.hikari.HikariDataSource import eventDemo.adapter.infrastructureLayer.event.GameEventBusInRabbinMQ import eventDemo.adapter.infrastructureLayer.event.GameEventStoreInPostgresql -import eventDemo.adapter.infrastructureLayer.event.projection.GameListRepositoryInMemory +import eventDemo.adapter.infrastructureLayer.event.projection.GameListRepositoryInRedis import eventDemo.adapter.infrastructureLayer.event.projection.GameProjectionBusInMemory -import eventDemo.adapter.infrastructureLayer.event.projection.GameStateRepositoryInMemory +import eventDemo.adapter.infrastructureLayer.event.projection.GameStateRepositoryInRedis import eventDemo.business.event.GameEventBus import eventDemo.business.event.GameEventStore import eventDemo.business.event.projection.GameProjectionBus @@ -19,10 +19,16 @@ import org.koin.core.module.dsl.singleOf import org.koin.core.scope.Scope import org.koin.core.scope.ScopeCallback import org.koin.dsl.bind +import redis.clients.jedis.JedisPooled +import redis.clients.jedis.UnifiedJedis import javax.sql.DataSource fun Module.configureDIInfrastructure(config: Configuration) { // Postgresql config + single { + JedisPooled(config.redisUrl) + } bind UnifiedJedis::class + single { HikariConfig() .apply { @@ -59,10 +65,10 @@ fun Module.configureDIInfrastructure(config: Configuration) { singleOf(::GameProjectionBusInMemory) bind GameProjectionBus::class single { - GameStateRepositoryInMemory(get(), snapshotConfig = SnapshotConfig()) + GameStateRepositoryInRedis(get(), get(), snapshotConfig = SnapshotConfig()) } bind GameStateRepository::class single { - GameListRepositoryInMemory(get(), snapshotConfig = SnapshotConfig()) + GameListRepositoryInRedis(get(), get(), snapshotConfig = SnapshotConfig()) } bind GameListRepository::class } diff --git a/src/test/kotlin/eventDemo/Helpers.kt b/src/test/kotlin/eventDemo/Helpers.kt index bf12d6c..d285984 100644 --- a/src/test/kotlin/eventDemo/Helpers.kt +++ b/src/test/kotlin/eventDemo/Helpers.kt @@ -72,4 +72,5 @@ fun UnifiedJedis.cleanProjections() { fun Koin.cleanDataTest() { get().cleanEventSource() + get().cleanProjections() } diff --git a/src/test/kotlin/eventDemo/business/event/projection/ProjectionSnapshotRepositoryTest.kt b/src/test/kotlin/eventDemo/business/event/projection/ProjectionSnapshotRepositoryTest.kt index e883c02..bbb84f6 100644 --- a/src/test/kotlin/eventDemo/business/event/projection/ProjectionSnapshotRepositoryTest.kt +++ b/src/test/kotlin/eventDemo/business/event/projection/ProjectionSnapshotRepositoryTest.kt @@ -51,6 +51,7 @@ class ProjectionSnapshotRepositoryTest : val projectionRepo = listOf( ::getSnapshotRepoInMemoryTest, + ::getSnapshotRepoInRedisTest, ) val list = diff --git a/src/test/kotlin/eventDemo/externalServices/RedisTest.kt b/src/test/kotlin/eventDemo/externalServices/RedisTest.kt index e55299a..6f08f20 100644 --- a/src/test/kotlin/eventDemo/externalServices/RedisTest.kt +++ b/src/test/kotlin/eventDemo/externalServices/RedisTest.kt @@ -11,7 +11,7 @@ class RedisTest : FunSpec({ tags(Tag.Redis) - xtest("test connection with jedis") { + test("test connection with jedis") { JedisPooled(redisUrl).also { it.set("test", "test") it.get("test") shouldBeEqual "test"