use GameEventStoreInPostgresql instead of InMemory
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
name: event-demo-dev
|
||||
include:
|
||||
- path:
|
||||
- parts/docker-compose-external.yaml
|
||||
- parts/docker-compose-databases.yaml
|
||||
- parts/docker-compose-tools.yaml
|
||||
- parts/docker-compose-traefik.yaml
|
||||
- envs/docker-compose-dev.yaml
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: event-demo-prod
|
||||
include:
|
||||
- path:
|
||||
- parts/docker-compose-external.yaml
|
||||
- parts/docker-compose-databases.yaml
|
||||
- parts/docker-compose-tools.yaml
|
||||
- parts/docker-compose-app.yaml
|
||||
- parts/docker-compose-traefik.yaml
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: event-demo-test
|
||||
include:
|
||||
- path:
|
||||
- parts/docker-compose-external.yaml
|
||||
- parts/docker-compose-databases.yaml
|
||||
- parts/docker-compose-port.yaml
|
||||
@@ -20,6 +20,7 @@ services:
|
||||
|
||||
postgresql:
|
||||
image: postgres:17.4
|
||||
command: postgres -c 'max_connections=500'
|
||||
environment:
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/postgresql_password
|
||||
POSTGRES_USER: event-demo
|
||||
@@ -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) },
|
||||
)
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
Reference in New Issue
Block a user