setting parent
This commit is contained in:
1 parent
f5a08268aa
commit
ba5231aaf6
2 files changed
+10
No files matched your search
@@ -51,6 +51,10 @@ open class EventDispatcher(val eventStore: EventStore, private val lifecycleStor
|
|||||||
//log.debug("Evaluating candidate: ${candidate::class.simpleName} for listener ${listener::class.simpleName}")
|
//log.debug("Evaluating candidate: ${candidate::class.simpleName} for listener ${listener::class.simpleName}")
|
||||||
try {
|
try {
|
||||||
val result = listener.onEvent(candidate, effectiveHistory)
|
val result = listener.onEvent(candidate, effectiveHistory)
|
||||||
|
if (result?.hasReferenceIdBeenSet() == false) {
|
||||||
|
log.warn { "ReferenceId is missing on produced event when dispatched ${candidate::class.simpleName}, setting this as parent for produced event!" }
|
||||||
|
result.apply { derivedOf(candidate) }
|
||||||
|
}
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
validateReferenceId(result, listener)
|
validateReferenceId(result, listener)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import kotlinx.coroutines.SupervisorJob
|
|||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.isActive
|
import kotlinx.coroutines.isActive
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import mu.KotlinLogging
|
||||||
import no.iktdev.eventi.models.Event
|
import no.iktdev.eventi.models.Event
|
||||||
import no.iktdev.eventi.models.Progress
|
import no.iktdev.eventi.models.Progress
|
||||||
import no.iktdev.eventi.models.Task
|
import no.iktdev.eventi.models.Task
|
||||||
@@ -23,6 +24,7 @@ import kotlin.coroutines.cancellation.CancellationException
|
|||||||
* @param reporter An instance of [TaskReporter] for reporting task status and events.
|
* @param reporter An instance of [TaskReporter] for reporting task status and events.
|
||||||
*/
|
*/
|
||||||
abstract class TaskListener(val taskType: TaskType = TaskType.CPU_INTENSIVE): TaskListenerImplementation {
|
abstract class TaskListener(val taskType: TaskType = TaskType.CPU_INTENSIVE): TaskListenerImplementation {
|
||||||
|
private val log = KotlinLogging.logger {}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
TaskListenerRegistry.registerListener(this)
|
TaskListenerRegistry.registerListener(this)
|
||||||
@@ -75,6 +77,10 @@ abstract class TaskListener(val taskType: TaskType = TaskType.CPU_INTENSIVE): Ta
|
|||||||
currentJob = getDispatcherForTask(task).launch {
|
currentJob = getDispatcherForTask(task).launch {
|
||||||
try {
|
try {
|
||||||
val result = onTask(task)
|
val result = onTask(task)
|
||||||
|
if (result?.hasReferenceIdBeenSet() == false) {
|
||||||
|
log.warn { "ReferenceId is missing on produced result event from task ${task.taskId} (${task.javaClass.simpleName}, derivation and reference id will be inherited from the task" }
|
||||||
|
result.apply { producedFrom(task) }
|
||||||
|
}
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
validateReferenceId(result, this@TaskListener)
|
validateReferenceId(result, this@TaskListener)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user