File tree Expand file tree Collapse file tree 2 files changed +10
-13
lines changed
main/kotlin/dev/helight/krescent/supervisor
test/kotlin/dev/helight/krescent/supervisor Expand file tree Collapse file tree 2 files changed +10
-13
lines changed Original file line number Diff line number Diff line change 11package dev.helight.krescent.supervisor
22
33import dev.helight.krescent.model.ReadModelBase
4- import dev.helight.krescent.model.ReadModelBase.Extension.catchup
4+ import dev.helight.krescent.model.ReadModelBase.Extension.strategy
55import dev.helight.krescent.model.ReadModelBase.Extension.stream
66import dev.helight.krescent.source.StreamingEventSource
7+ import dev.helight.krescent.source.strategy.StreamingSourcingStrategy
78import org.slf4j.LoggerFactory
89import kotlin.math.min
910import kotlin.math.pow
@@ -46,19 +47,15 @@ class BalancedReadModelJob(
4647 }
4748
4849 override suspend fun run (supervisor : ModelSupervisor ) {
49- if (preventParallelCatchup) try {
50- val source = sourceSupplier()
51- val model = modelSupplier()
52- logger.debug(" BalancedReadModelJob starting catchup phase for {}." , model)
53- model.catchup(source)
54- } finally {
55- supervisor.startupMutex.unlock(this )
56- }
57-
5850 val source = sourceSupplier()
5951 val model = modelSupplier()
60- logger.debug(" BalancedReadModelJob starting streaming phase for {}." , model)
61- model.stream(source)
52+ if (preventParallelCatchup) {
53+ model.strategy(source, StreamingSourcingStrategy {
54+ supervisor.startupMutex.unlock(this )
55+ })
56+ } else {
57+ model.stream(source)
58+ }
6259 }
6360
6461 override suspend fun onExited (supervisor : ModelSupervisor ) {
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ class BalancedReadModelJobTest {
4343
4444 // Expect book 1 -> 9 copies, book 2 -> 5 copies (as per simulated stream)
4545 assertEquals(mapOf (" 1" to 9 , " 2" to 5 ), target)
46- assertEquals(3 , creationCounter)
46+ assertEquals(2 , creationCounter)
4747 }
4848 }
4949
You can’t perform that action at this time.
0 commit comments