Updated check
This commit is contained in:
parent
46b053eaf0
commit
44e34cead6
@ -82,8 +82,8 @@ class CompleteMediaTask(@Autowired override var coordinator: EventCoordinator) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
val isWaitingForPrecondition = isAwaitingPrecondition(taskEvents, events)
|
val isWaitingForPrecondition = isAwaitingPrecondition(taskEvents, events)
|
||||||
if (isWaitingForPrecondition) {
|
if (isWaitingForPrecondition.isNotEmpty()) {
|
||||||
log.info { "Waiting for preconditions" }
|
log.info { "Waiting for preconditions: ${isWaitingForPrecondition.keys.joinToString(",") }}" }
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,12 +6,13 @@ import no.iktdev.mediaprocessing.shared.common.task.TaskType
|
|||||||
import no.iktdev.mediaprocessing.shared.kafka.core.KafkaEvents
|
import no.iktdev.mediaprocessing.shared.kafka.core.KafkaEvents
|
||||||
|
|
||||||
|
|
||||||
fun isAwaitingPrecondition(tasks: List<TaskType>, events: List<PersistentMessage>): Boolean {
|
fun isAwaitingPrecondition(tasks: List<TaskType>, events: List<PersistentMessage>): Map<TaskType, Boolean> {
|
||||||
|
val response = mutableMapOf<TaskType, Boolean>()
|
||||||
if (tasks.any { it == TaskType.Encode }) {
|
if (tasks.any { it == TaskType.Encode }) {
|
||||||
if (events.lastOrNull { it.isOfEvent(
|
if (events.lastOrNull { it.isOfEvent(
|
||||||
KafkaEvents.EventMediaParameterEncodeCreated
|
KafkaEvents.EventMediaParameterEncodeCreated
|
||||||
) } == null) {
|
) } == null) {
|
||||||
return true
|
response[TaskType.Encode] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,12 +21,12 @@ fun isAwaitingPrecondition(tasks: List<TaskType>, events: List<PersistentMessage
|
|||||||
if (events.lastOrNull { it.isOfEvent(
|
if (events.lastOrNull { it.isOfEvent(
|
||||||
KafkaEvents.EventWorkConvertCreated
|
KafkaEvents.EventWorkConvertCreated
|
||||||
) } == null) {
|
) } == null) {
|
||||||
return true
|
response[TaskType.Convert] = true
|
||||||
}
|
}
|
||||||
} else if (tasks.any { it == TaskType.Convert }) {
|
} else if (tasks.any { it == TaskType.Convert }) {
|
||||||
val extractEvent = events.lastOrNull { it.isOfEvent(KafkaEvents.EventMediaParameterExtractCreated) }
|
val extractEvent = events.lastOrNull { it.isOfEvent(KafkaEvents.EventMediaParameterExtractCreated) }
|
||||||
if (extractEvent == null || extractEvent.isSuccess()) {
|
if (extractEvent == null || extractEvent.isSuccess()) {
|
||||||
return true
|
response[TaskType.Convert] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,12 +34,12 @@ fun isAwaitingPrecondition(tasks: List<TaskType>, events: List<PersistentMessage
|
|||||||
if (events.lastOrNull { it.isOfEvent(
|
if (events.lastOrNull { it.isOfEvent(
|
||||||
KafkaEvents.EventMediaParameterExtractCreated
|
KafkaEvents.EventMediaParameterExtractCreated
|
||||||
) } == null) {
|
) } == null) {
|
||||||
return true
|
response[TaskType.Extract] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return false
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user