einige Ergänzungen
This commit is contained in:
+1
-8
@@ -3,11 +3,9 @@ package at.mocode.infrastructure.cache.redis
|
||||
import at.mocode.infrastructure.cache.api.CacheConfiguration
|
||||
import at.mocode.infrastructure.cache.api.CacheSerializer
|
||||
import at.mocode.infrastructure.cache.api.ConnectionState
|
||||
import at.mocode.infrastructure.cache.api.ConnectionStateListener
|
||||
import at.mocode.infrastructure.cache.api.DefaultCacheConfiguration
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
@@ -22,12 +20,7 @@ import org.testcontainers.junit.jupiter.Container
|
||||
import org.testcontainers.junit.jupiter.Testcontainers
|
||||
import org.testcontainers.utility.DockerImageName
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertNull
|
||||
import kotlin.test.assertTrue
|
||||
import kotlin.test.*
|
||||
|
||||
@Testcontainers
|
||||
class RedisDistributedCacheTest {
|
||||
|
||||
+1
-2
@@ -6,9 +6,8 @@ import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import com.fasterxml.jackson.databind.SerializationFeature
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
|
||||
import com.fasterxml.jackson.module.kotlin.KotlinModule
|
||||
import com.fasterxml.jackson.module.kotlin.readValue
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.util.UUID
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
|
||||
+1
-7
@@ -4,15 +4,9 @@ import at.mocode.core.domain.event.DomainEvent
|
||||
import at.mocode.infrastructure.eventstore.api.EventSerializer
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.data.domain.Range
|
||||
import org.springframework.data.redis.connection.stream.Consumer
|
||||
import org.springframework.data.redis.connection.stream.MapRecord
|
||||
import org.springframework.data.redis.connection.stream.ReadOffset
|
||||
import org.springframework.data.redis.connection.stream.StreamOffset
|
||||
import org.springframework.data.redis.connection.stream.StreamReadOptions
|
||||
import org.springframework.data.redis.connection.stream.*
|
||||
import org.springframework.data.redis.core.StringRedisTemplate
|
||||
import org.springframework.scheduling.annotation.Scheduled
|
||||
import java.time.Duration
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import javax.annotation.PostConstruct
|
||||
|
||||
+3
-6
@@ -7,19 +7,16 @@ import at.mocode.infrastructure.eventstore.api.EventStore
|
||||
import at.mocode.infrastructure.eventstore.api.Subscription
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.data.redis.connection.stream.MapRecord
|
||||
import org.springframework.data.redis.connection.stream.ObjectRecord
|
||||
import org.springframework.data.redis.connection.stream.ReadOffset
|
||||
import org.springframework.data.redis.connection.stream.Record
|
||||
import org.springframework.data.redis.connection.stream.StreamOffset
|
||||
import org.springframework.data.redis.connection.stream.StreamReadOptions
|
||||
import org.springframework.data.redis.core.StringRedisTemplate
|
||||
import org.springframework.data.redis.stream.StreamListener
|
||||
import org.springframework.data.redis.stream.StreamMessageListenerContainer
|
||||
import org.springframework.data.redis.stream.Subscription as RedisSubscription
|
||||
import java.time.Duration
|
||||
import java.util.UUID
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import org.springframework.data.redis.stream.Subscription as RedisSubscription
|
||||
|
||||
/**
|
||||
* Redis Streams implementation of EventStore.
|
||||
@@ -91,7 +88,7 @@ class RedisEventStore(
|
||||
val result = redisTemplate.opsForStream<String, String>()
|
||||
.add(streamKey, eventData)
|
||||
|
||||
logger.debug("Appended event ${event.eventId} to stream $streamId with ID $result")
|
||||
logger.debug("Appended event {} to stream {} with ID {}", event.eventId, streamId, result)
|
||||
|
||||
// Also append to the all events stream
|
||||
val allEventsStreamKey = getAllEventsStreamKey()
|
||||
|
||||
+5
-57
@@ -1,63 +1,11 @@
|
||||
package at.mocode.infrastructure.gateway.config
|
||||
|
||||
import io.ktor.server.application.*
|
||||
import org.jetbrains.exposed.sql.Database
|
||||
import org.jetbrains.exposed.sql.SchemaUtils
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
/**
|
||||
* Database configuration for the API Gateway.
|
||||
*
|
||||
* Sets up database connections and schema initialization for all bounded contexts.
|
||||
* The gateway uses DatabaseFactory.init() in Application.kt for proper connection pooling.
|
||||
* Schema initialization is handled by individual services in their @PostConstruct methods
|
||||
* to prevent race conditions and maintain proper separation of concerns.
|
||||
*
|
||||
* This file is kept for potential future gateway-specific database utilities.
|
||||
*/
|
||||
fun Application.configureDatabase() {
|
||||
val log = LoggerFactory.getLogger("DatabaseConfig")
|
||||
val databaseUrl = environment.config.propertyOrNull("database.url")?.getString()
|
||||
?: "jdbc:postgresql://localhost:5432/meldestelle"
|
||||
val databaseUser = environment.config.propertyOrNull("database.user")?.getString()
|
||||
?: "meldestelle_user"
|
||||
val databasePassword = environment.config.propertyOrNull("database.password")?.getString()
|
||||
?: "meldestelle_password"
|
||||
|
||||
// Initialize database connection
|
||||
Database.connect(
|
||||
url = databaseUrl,
|
||||
driver = "org.postgresql.Driver",
|
||||
user = databaseUser,
|
||||
password = databasePassword
|
||||
)
|
||||
|
||||
// Initialize database schemas for all contexts
|
||||
transaction {
|
||||
// Import table definitions from all contexts
|
||||
try {
|
||||
// Master Data Context tables
|
||||
SchemaUtils.createMissingTablesAndColumns(
|
||||
at.mocode.masterdata.infrastructure.persistence.LandTable
|
||||
)
|
||||
|
||||
// Member Management Context tables
|
||||
// TODO: Uncomment once the members module is fully migrated
|
||||
// SchemaUtils.createMissingTablesAndColumns(
|
||||
// at.mocode.members.infrastructure.persistence.PersonTable,
|
||||
// at.mocode.members.infrastructure.persistence.VereinTable
|
||||
// )
|
||||
|
||||
// Horse Registry Context tables
|
||||
SchemaUtils.createMissingTablesAndColumns(
|
||||
at.mocode.horses.infrastructure.persistence.HorseTable
|
||||
)
|
||||
|
||||
// Event Management Context tables
|
||||
SchemaUtils.createMissingTablesAndColumns(
|
||||
at.mocode.events.infrastructure.persistence.VeranstaltungTable
|
||||
)
|
||||
|
||||
log.info("Database schemas initialized successfully")
|
||||
} catch (e: Exception) {
|
||||
log.error("Failed to initialize database schemas: ${e.message}")
|
||||
// In production, you might want to fail fast here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user