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)
|
||||
if (isWaitingForPrecondition) {
|
||||
log.info { "Waiting for preconditions" }
|
||||
if (isWaitingForPrecondition.isNotEmpty()) {
|
||||
log.info { "Waiting for preconditions: ${isWaitingForPrecondition.keys.joinToString(",") }}" }
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@ -6,12 +6,13 @@ import no.iktdev.mediaprocessing.shared.common.task.TaskType
|
||||
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 (events.lastOrNull { it.isOfEvent(
|
||||
KafkaEvents.EventMediaParameterEncodeCreated
|
||||
) } == null) {
|
||||
return true
|
||||
response[TaskType.Encode] = true
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,12 +21,12 @@ fun isAwaitingPrecondition(tasks: List<TaskType>, events: List<PersistentMessage
|
||||
if (events.lastOrNull { it.isOfEvent(
|
||||
KafkaEvents.EventWorkConvertCreated
|
||||
) } == null) {
|
||||
return true
|
||||
response[TaskType.Convert] = true
|
||||
}
|
||||
} else if (tasks.any { it == TaskType.Convert }) {
|
||||
val extractEvent = events.lastOrNull { it.isOfEvent(KafkaEvents.EventMediaParameterExtractCreated) }
|
||||
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(
|
||||
KafkaEvents.EventMediaParameterExtractCreated
|
||||
) } == null) {
|
||||
return true
|
||||
response[TaskType.Extract] = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false
|
||||
return response
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user