RunnerJobVODWebVideoTranscodingPayload,
RunnerJobVODWebVideoTranscodingPrivatePayload
} from '@shared/models'
+import { throttle } from 'lodash'
type CreateRunnerJobArg =
{
protected readonly lTags = loggerTagsFactory('runner')
+ static setJobAsUpdatedThrottled = throttle(setAsUpdated, 2000)
+
// ---------------------------------------------------------------------------
abstract create (options: C): Promise<MRunnerJob>
if (progress) runnerJob.progress = progress
+ if (!runnerJob.changed()) {
+ try {
+ await AbstractJobHandler.setJobAsUpdatedThrottled({ sequelize: sequelizeTypescript, table: 'runnerJob', id: runnerJob.id })
+ } catch (err) {
+ logger.warn('Cannot set remote job as updated', { err, ...this.lTags(runnerJob.id, runnerJob.type) })
+ }
+
+ return
+ }
+
await retryTransactionWrapper(() => {
return sequelizeTypescript.transaction(async transaction => {
- if (runnerJob.changed()) {
- return runnerJob.save({ transaction })
- }
-
- // Don't update the job too often
- if (new Date().getTime() - runnerJob.updatedAt.getTime() > 2000) {
- await setAsUpdated({ sequelize: sequelizeTypescript, table: 'runnerJob', id: runnerJob.id, transaction })
- }
+ return runnerJob.save({ transaction })
})
})
}