diff --git a/src/main/kotlin/eventDemo/adapter/infrastructureLayer/event/GameEventBusInMemory.kt b/src/main/kotlin/eventDemo/adapter/infrastructureLayer/event/GameEventBusInMemory.kt index 814a3a1..013feac 100644 --- a/src/main/kotlin/eventDemo/adapter/infrastructureLayer/event/GameEventBusInMemory.kt +++ b/src/main/kotlin/eventDemo/adapter/infrastructureLayer/event/GameEventBusInMemory.kt @@ -1,11 +1,10 @@ package eventDemo.adapter.infrastructureLayer.event -import eventDemo.business.entity.GameId import eventDemo.business.event.GameEventBus import eventDemo.business.event.event.GameEvent -import eventDemo.libs.event.EventBus -import eventDemo.libs.event.EventBusInMemory +import eventDemo.libs.bus.Bus +import eventDemo.libs.bus.BusInMemory class GameEventBusInMemory : GameEventBus(), - EventBus by EventBusInMemory() + Bus by BusInMemory() diff --git a/src/main/kotlin/eventDemo/business/event/GameEventBus.kt b/src/main/kotlin/eventDemo/business/event/GameEventBus.kt index 6d6d4d0..abc9c93 100644 --- a/src/main/kotlin/eventDemo/business/event/GameEventBus.kt +++ b/src/main/kotlin/eventDemo/business/event/GameEventBus.kt @@ -1,12 +1,11 @@ package eventDemo.business.event -import eventDemo.business.entity.GameId import eventDemo.business.event.event.GameEvent -import eventDemo.libs.event.EventBus +import eventDemo.libs.bus.Bus import java.util.UUID abstract class GameEventBus : - EventBus, + Bus, Comparable { private val instanceId: UUID = UUID.randomUUID() diff --git a/src/main/kotlin/eventDemo/libs/event/EventBus.kt b/src/main/kotlin/eventDemo/libs/bus/Bus.kt similarity index 61% rename from src/main/kotlin/eventDemo/libs/event/EventBus.kt rename to src/main/kotlin/eventDemo/libs/bus/Bus.kt index dbf87e3..f98d2fd 100644 --- a/src/main/kotlin/eventDemo/libs/event/EventBus.kt +++ b/src/main/kotlin/eventDemo/libs/bus/Bus.kt @@ -1,7 +1,7 @@ -package eventDemo.libs.event +package eventDemo.libs.bus -interface EventBus, ID : AggregateId> { - fun publish(event: E) +interface Bus { + fun publish(item: E) /** * @param priority The higher the priority, the more it will be called first diff --git a/src/main/kotlin/eventDemo/libs/event/EventBusInMemory.kt b/src/main/kotlin/eventDemo/libs/bus/BusInMemory.kt similarity index 67% rename from src/main/kotlin/eventDemo/libs/event/EventBusInMemory.kt rename to src/main/kotlin/eventDemo/libs/bus/BusInMemory.kt index b546a12..66f1fa3 100644 --- a/src/main/kotlin/eventDemo/libs/event/EventBusInMemory.kt +++ b/src/main/kotlin/eventDemo/libs/bus/BusInMemory.kt @@ -1,18 +1,18 @@ -package eventDemo.libs.event +package eventDemo.libs.bus import io.github.oshai.kotlinlogging.withLoggingContext import kotlinx.coroutines.runBlocking -class EventBusInMemory, ID : AggregateId> : EventBus { +class BusInMemory : Bus { private val subscribers: MutableList Unit>> = mutableListOf() - override fun publish(event: E) { + override fun publish(item: E) { subscribers .sortedByDescending { (priority, _) -> priority } .forEach { (_, block) -> runBlocking { - withLoggingContext("event" to event.toString()) { - block(event) + withLoggingContext("busItem" to item.toString()) { + block(item) } } }