use GameEventStoreInPostgresql instead of InMemory

This commit is contained in:
2025-03-29 03:31:13 +01:00
parent d9e05e6d9a
commit 7d030204f6
7 changed files with 30 additions and 6 deletions

View File

@@ -0,0 +1,21 @@
package eventDemo.adapter.infrastructureLayer.event
import eventDemo.business.entity.GameId
import eventDemo.business.event.GameEventStore
import eventDemo.business.event.event.GameEvent
import eventDemo.libs.event.EventStore
import eventDemo.libs.event.EventStoreInPostgresql
import kotlinx.serialization.json.Json
import javax.sql.DataSource
/**
* A stream to publish and read the played card event.
*/
class GameEventStoreInPostgresql(
dataSource: DataSource,
) : GameEventStore,
EventStore<GameEvent, GameId> by EventStoreInPostgresql(
dataSource,
{ Json.encodeToString(it) },
{ Json.decodeFromString(it) },
)

View File

@@ -3,7 +3,7 @@ package eventDemo.configuration.injection
import com.zaxxer.hikari.HikariConfig
import com.zaxxer.hikari.HikariDataSource
import eventDemo.adapter.infrastructureLayer.event.GameEventBusInMemory
import eventDemo.adapter.infrastructureLayer.event.GameEventStoreInMemory
import eventDemo.adapter.infrastructureLayer.event.GameEventStoreInPostgresql
import eventDemo.adapter.infrastructureLayer.event.projection.GameListRepositoryInMemory
import eventDemo.adapter.infrastructureLayer.event.projection.GameProjectionBusInMemory
import eventDemo.adapter.infrastructureLayer.event.projection.GameStateRepositoryInRedis
@@ -31,13 +31,15 @@ fun Module.configureDIInfrastructure(config: Configuration) {
jdbcUrl = config.postgresql.url
username = config.postgresql.username
password = config.postgresql.password
maximumPoolSize = 50
minimumIdle = 20
}.let {
HikariDataSource(it)
}
} bind DataSource::class
singleOf(::GameEventBusInMemory) bind GameEventBus::class
singleOf(::GameEventStoreInMemory) bind GameEventStore::class
singleOf(::GameEventStoreInPostgresql) bind GameEventStore::class
singleOf(::GameProjectionBusInMemory) bind GameProjectionBus::class
single {

View File

@@ -15,7 +15,7 @@ import org.junit.jupiter.api.assertThrows
import kotlin.test.assertNotNull
@DelicateCoroutinesApi
class EventStreamInMemoryTest :
class EventStreamTest :
FunSpec({
fun EventStream<EventXTest, IdTest>.with3Events(block: EventStream<EventXTest, IdTest>.(id: IdTest) -> Unit) =
also {