import * as redis from './redis.js'
import { updateVersionProcessor, registerLatestVersionListener } from './version.js'

const { getQueue, subClient } = redis

export default function createQueues () {
  if (redis.isEnabled()) {
    const updateVersionQueue = getQueue('update-version')
    updateVersionQueue.process(updateVersionProcessor)
    updateVersionQueue.add({}, {
      jobId: 'update-version-job',
      repeat: { every: Number(process.env.CACHE_TTL) },
      removeOnComplete: true
    })
  }

  // not a queue but though, used by redis
  registerLatestVersionListener(subClient)
}