21 lines
648 B
TypeScript
21 lines
648 B
TypeScript
import { Job } from "bullmq";
|
|
import { cacheQueue, cacheQueueEvents } from "../queues/cacheQueue";
|
|
|
|
type CachePath = string;
|
|
|
|
export async function getSourceVideo(job: Job, timeout: number = 1000 * 60 * 60 * 5): Promise<CachePath> {
|
|
const vodId = job.data.vodId;
|
|
|
|
await job.log(`First we need to get the vod from cache...`);
|
|
const cacheGetJob = await cacheQueue.add(
|
|
'cacheGet',
|
|
{ vodId },
|
|
{ jobId: `cacheGet-${vodId}` }
|
|
);
|
|
|
|
const results = (await cacheGetJob.waitUntilFinished(cacheQueueEvents, timeout));
|
|
await job.log(`cacheGet results: ${JSON.stringify(results)}`);
|
|
const { cachePath } = results;
|
|
|
|
return cachePath
|
|
} |