Queue guest document extraction
All checks were successful
build-and-deploy / build-deploy (push) Successful in 3m36s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 3m36s
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.android.trisolarisserver.component
|
||||
|
||||
import jakarta.annotation.PreDestroy
|
||||
import org.springframework.stereotype.Component
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
@Component
|
||||
class ExtractionQueue {
|
||||
private val executor = Executors.newSingleThreadExecutor { runnable ->
|
||||
Thread(runnable, "doc-extraction-queue").apply { isDaemon = true }
|
||||
}
|
||||
|
||||
fun enqueue(task: () -> Unit) {
|
||||
executor.submit {
|
||||
try {
|
||||
task()
|
||||
} catch (_: Exception) {
|
||||
// Best-effort processing; failures should not crash the worker.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
fun shutdown() {
|
||||
executor.shutdown()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user