re enable Redis

This commit is contained in:
2025-04-12 22:57:47 +02:00
parent 19c39678cf
commit d394fca3f9
5 changed files with 17 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
package eventDemo.configuration.business package eventDemo.configuration.business
import eventDemo.adapter.infrastructureLayer.event.projection.GameListRepositoryInMemory import eventDemo.adapter.infrastructureLayer.event.projection.GameListRepositoryInRedis
import eventDemo.adapter.infrastructureLayer.event.projection.GameStateRepositoryInMemory import eventDemo.adapter.infrastructureLayer.event.projection.GameStateRepositoryInRedis
import eventDemo.business.command.GameCommandHandler import eventDemo.business.command.GameCommandHandler
import eventDemo.business.event.projection.projectionListener.ReactionListener import eventDemo.business.event.projection.projectionListener.ReactionListener
import org.koin.core.Koin import org.koin.core.Koin
@@ -10,10 +10,10 @@ fun Koin.configureGameListener() {
get<GameCommandHandler>() get<GameCommandHandler>()
.subscribeToBus(get()) .subscribeToBus(get())
get<GameStateRepositoryInMemory>() get<GameStateRepositoryInRedis>()
.subscribeToBus(get(), get()) .subscribeToBus(get(), get())
get<GameListRepositoryInMemory>() get<GameListRepositoryInRedis>()
.subscribeToBus(get(), get()) .subscribeToBus(get(), get())
get<ReactionListener>() get<ReactionListener>()

View File

@@ -5,9 +5,9 @@ import com.zaxxer.hikari.HikariConfig
import com.zaxxer.hikari.HikariDataSource import com.zaxxer.hikari.HikariDataSource
import eventDemo.adapter.infrastructureLayer.event.GameEventBusInRabbinMQ import eventDemo.adapter.infrastructureLayer.event.GameEventBusInRabbinMQ
import eventDemo.adapter.infrastructureLayer.event.GameEventStoreInPostgresql 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.GameProjectionBusInMemory
import eventDemo.adapter.infrastructureLayer.event.projection.GameStateRepositoryInMemory import eventDemo.adapter.infrastructureLayer.event.projection.GameStateRepositoryInRedis
import eventDemo.business.event.GameEventBus import eventDemo.business.event.GameEventBus
import eventDemo.business.event.GameEventStore import eventDemo.business.event.GameEventStore
import eventDemo.business.event.projection.GameProjectionBus 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.Scope
import org.koin.core.scope.ScopeCallback import org.koin.core.scope.ScopeCallback
import org.koin.dsl.bind import org.koin.dsl.bind
import redis.clients.jedis.JedisPooled
import redis.clients.jedis.UnifiedJedis
import javax.sql.DataSource import javax.sql.DataSource
fun Module.configureDIInfrastructure(config: Configuration) { fun Module.configureDIInfrastructure(config: Configuration) {
// Postgresql config // Postgresql config
single {
JedisPooled(config.redisUrl)
} bind UnifiedJedis::class
single { single {
HikariConfig() HikariConfig()
.apply { .apply {
@@ -59,10 +65,10 @@ fun Module.configureDIInfrastructure(config: Configuration) {
singleOf(::GameProjectionBusInMemory) bind GameProjectionBus::class singleOf(::GameProjectionBusInMemory) bind GameProjectionBus::class
single { single {
GameStateRepositoryInMemory(get(), snapshotConfig = SnapshotConfig()) GameStateRepositoryInRedis(get(), get(), snapshotConfig = SnapshotConfig())
} bind GameStateRepository::class } bind GameStateRepository::class
single { single {
GameListRepositoryInMemory(get(), snapshotConfig = SnapshotConfig()) GameListRepositoryInRedis(get(), get(), snapshotConfig = SnapshotConfig())
} bind GameListRepository::class } bind GameListRepository::class
} }

View File

@@ -72,4 +72,5 @@ fun UnifiedJedis.cleanProjections() {
fun Koin.cleanDataTest() { fun Koin.cleanDataTest() {
get<DataSource>().cleanEventSource() get<DataSource>().cleanEventSource()
get<UnifiedJedis>().cleanProjections()
} }

View File

@@ -51,6 +51,7 @@ class ProjectionSnapshotRepositoryTest :
val projectionRepo = val projectionRepo =
listOf( listOf(
::getSnapshotRepoInMemoryTest, ::getSnapshotRepoInMemoryTest,
::getSnapshotRepoInRedisTest,
) )
val list = val list =

View File

@@ -11,7 +11,7 @@ class RedisTest :
FunSpec({ FunSpec({
tags(Tag.Redis) tags(Tag.Redis)
xtest("test connection with jedis") { test("test connection with jedis") {
JedisPooled(redisUrl).also { JedisPooled(redisUrl).also {
it.set("test", "test") it.set("test", "test")
it.get("test") shouldBeEqual "test" it.get("test") shouldBeEqual "test"