Skip to content

Commit

Permalink
Switched jobs to use redis from a remote cluster.
Browse files Browse the repository at this point in the history
  • Loading branch information
rizen committed Oct 28, 2024
1 parent 973be73 commit a4670ca
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ving/jobs/queue.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import { jobHandlers } from '#ving/jobs/map.mjs';
* getQueue();
*/
export const getQueue = (options = {}) => {
const queue = new Queue(options?.queueName || 'jobs', { connection: useRedis() });
const params = { connection: useRedis() };
if (params.connection.isCluster) {
params.prefix = 'vingjobs';
}
const queue = new Queue(options?.queueName || 'jobs', params);
return queue;
}

Expand Down Expand Up @@ -47,7 +51,6 @@ export const addJob = async (type, data = {}, options = { queueName: 'jobs' }) =
throw ving.ouch(404, `Job handler ${type} is not available.`);
const queue = getQueue(options);
const jobOptions = {
// connection: useRedis(),
removeOnComplete: {
age: 3600, // keep up to 1 hour
count: 1000, // keep up to 1000 jobs
Expand Down

0 comments on commit a4670ca

Please sign in to comment.