move EventStream method implementation into the interface
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package eventDemo.libs.event
|
||||
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import io.github.oshai.kotlinlogging.withLoggingContext
|
||||
import java.util.Queue
|
||||
import java.util.concurrent.ConcurrentLinkedQueue
|
||||
|
||||
@@ -21,27 +20,11 @@ class EventStreamInMemory<E : Event<*>> : EventStream<E> {
|
||||
}
|
||||
}
|
||||
|
||||
override fun publish(vararg events: E) {
|
||||
events.forEach {
|
||||
withLoggingContext("event" to it.toString()) {
|
||||
publish(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun readAll(): Set<E> =
|
||||
events.toSet()
|
||||
|
||||
override fun readGreaterOfVersion(version: Int): Set<E> =
|
||||
events
|
||||
.filter { it.version > version }
|
||||
.toSet()
|
||||
|
||||
override fun readVersionBetween(version: IntRange): Set<E> =
|
||||
events
|
||||
.filter { version.contains(it.version) }
|
||||
.toSet()
|
||||
|
||||
override fun getByVersion(version: Int): E? =
|
||||
events.find { version == it.version }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user