fix and improve ProjectionSnapshotRepositoryInRedis
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
package eventDemo.libs.bus
|
||||
|
||||
import io.github.oshai.kotlinlogging.withLoggingContext
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
|
||||
class BusInMemory<E> : Bus<E> {
|
||||
private val subscribers: MutableList<Pair<Int, suspend (E) -> Unit>> = mutableListOf()
|
||||
|
||||
override fun publish(item: E) {
|
||||
subscribers
|
||||
.sortedByDescending { (priority, _) -> priority }
|
||||
.forEach { (_, block) ->
|
||||
runBlocking {
|
||||
withLoggingContext("busItem" to item.toString()) {
|
||||
override suspend fun publish(item: E) {
|
||||
withLoggingContext("busItem" to item.toString()) {
|
||||
subscribers
|
||||
.sortedByDescending { (priority, _) -> priority }
|
||||
.forEach { (_, block) ->
|
||||
coroutineScope {
|
||||
block(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun subscribe(
|
||||
|
||||
Reference in New Issue
Block a user