Processer now allows for adhoc origins
This commit is contained in:
parent
1543ef6aba
commit
14a366f035
@ -15,4 +15,5 @@ public class DefaultProcesserConfiguration: Defaults() {
|
|||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
class SocketImplemented: SocketImplementation() {
|
class SocketImplemented: SocketImplementation() {
|
||||||
|
override var additionalOrigins: List<String> = ProcesserEnv.wsAllowedOrigins.split(",")
|
||||||
}
|
}
|
||||||
@ -5,6 +5,8 @@ import java.io.File
|
|||||||
|
|
||||||
class ProcesserEnv {
|
class ProcesserEnv {
|
||||||
companion object {
|
companion object {
|
||||||
|
val wsAllowedOrigins: String = System.getenv("AllowedOriginsWebsocket")?.takeIf { it.isNotBlank() } ?: ""
|
||||||
|
|
||||||
val ffmpeg: String = System.getenv("SUPPORTING_EXECUTABLE_FFMPEG") ?: "ffmpeg"
|
val ffmpeg: String = System.getenv("SUPPORTING_EXECUTABLE_FFMPEG") ?: "ffmpeg"
|
||||||
val allowOverwrite = System.getenv("ALLOW_OVERWRITE").toBoolean() ?: false
|
val allowOverwrite = System.getenv("ALLOW_OVERWRITE").toBoolean() ?: false
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package no.iktdev.mediaprocessing.processer
|
|||||||
import mu.KotlinLogging
|
import mu.KotlinLogging
|
||||||
import no.iktdev.mediaprocessing.shared.common.SharedConfig
|
import no.iktdev.mediaprocessing.shared.common.SharedConfig
|
||||||
import no.iktdev.mediaprocessing.shared.common.contract.dto.ProcesserEventInfo
|
import no.iktdev.mediaprocessing.shared.common.contract.dto.ProcesserEventInfo
|
||||||
|
import no.iktdev.mediaprocessing.shared.common.task.Task
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
import org.springframework.messaging.simp.SimpMessagingTemplate
|
import org.springframework.messaging.simp.SimpMessagingTemplate
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
@ -17,6 +18,23 @@ class Reporter() {
|
|||||||
|
|
||||||
private val log = KotlinLogging.logger {}
|
private val log = KotlinLogging.logger {}
|
||||||
|
|
||||||
|
|
||||||
|
fun encodeTaskAssigned(task: Task) {
|
||||||
|
try {
|
||||||
|
messageTemplate.convertAndSend("/topic/encode/assigned", task)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
//log.error { e.message }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun extractTaskAssigned(task: Task) {
|
||||||
|
try {
|
||||||
|
messageTemplate.convertAndSend("/topic/extract/assigned", task)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
//log.error { e.message }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun sendEncodeProgress(progress: ProcesserEventInfo) {
|
fun sendEncodeProgress(progress: ProcesserEventInfo) {
|
||||||
try {
|
try {
|
||||||
restTemplate.postForEntity(SharedConfig.uiUrl + "/encode/progress", progress, String::class.java)
|
restTemplate.postForEntity(SharedConfig.uiUrl + "/encode/progress", progress, String::class.java)
|
||||||
|
|||||||
@ -56,6 +56,7 @@ class EncodeService(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onTaskAssigned(task: Task) {
|
override fun onTaskAssigned(task: Task) {
|
||||||
|
reporter.encodeTaskAssigned(task)
|
||||||
startEncode(task)
|
startEncode(task)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -55,6 +55,7 @@ class ExtractService(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onTaskAssigned(task: Task) {
|
override fun onTaskAssigned(task: Task) {
|
||||||
|
reporter.extractTaskAssigned(task)
|
||||||
startExtract(task)
|
startExtract(task)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,10 +8,14 @@ import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerCo
|
|||||||
|
|
||||||
@EnableWebSocketMessageBroker
|
@EnableWebSocketMessageBroker
|
||||||
open class SocketImplementation: WebSocketMessageBrokerConfigurer {
|
open class SocketImplementation: WebSocketMessageBrokerConfigurer {
|
||||||
|
open val defaultOrigins = listOf("*://localhost:*/*", "http://localhost:3000/")
|
||||||
|
open var additionalOrigins: List<String> = emptyList()
|
||||||
|
|
||||||
override fun registerStompEndpoints(registry: StompEndpointRegistry) {
|
override fun registerStompEndpoints(registry: StompEndpointRegistry) {
|
||||||
|
val origins = (defaultOrigins + additionalOrigins).toTypedArray()
|
||||||
|
println("Allowing the following origins for websocket connection\n\t${origins.joinToString("\n\t")}")
|
||||||
registry.addEndpoint("/ws")
|
registry.addEndpoint("/ws")
|
||||||
.setAllowedOrigins("*://localhost:*/*", "http://localhost:3000/")
|
.setAllowedOrigins(*origins)
|
||||||
.withSockJS()
|
.withSockJS()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user