Skip to content

Commit

Permalink
Change queue name to enum type
Browse files Browse the repository at this point in the history
  • Loading branch information
FyreByrd committed Oct 24, 2024
1 parent ff09eed commit 4616cba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions source/SIL.AppBuilder.Portal/common/bullmq.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { Queue } from 'bullmq';
import type { ScriptoriaJob } from './BullJobTypes.js';

export type QueueName = 'scriptoria' | 'default recurring';
export enum QueueName {
Scriptoria = 'scriptoria',
DefaultRecurring = 'default recurring'
};

export const scriptoria = new Queue<ScriptoriaJob>('scriptoria' as QueueName, {
export const scriptoria = new Queue<ScriptoriaJob>(QueueName.Scriptoria, {
connection: {
host: process.env.NODE_ENV === 'development' ? 'localhost' : 'redis'
}
});

export const default_recurring = new Queue<ScriptoriaJob>('default recurring' as QueueName, {
export const default_recurring = new Queue<ScriptoriaJob>(QueueName.DefaultRecurring, {
connection: {
host: process.env.NODE_ENV === 'development' ? 'localhost' : 'redis'
}
Expand Down
4 changes: 2 additions & 2 deletions source/SIL.AppBuilder.Portal/node-server/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ app.listen(3000, () => console.log('Dev server started'));

addDefaultRecurringJobs();

new ScriptoriaWorker('scriptoria');
new ScriptoriaWorker('default recurring');
new ScriptoriaWorker(queues.QueueName.Scriptoria);
new ScriptoriaWorker(queues.QueueName.DefaultRecurring);
4 changes: 2 additions & 2 deletions source/SIL.AppBuilder.Portal/node-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ import { BullMQ, queues } from 'sil.appbuilder.portal.common';
// Running on svelte process right now. Consider putting on new thread
// Fine like this if majority of job time is waiting for network requests
// If there is much processing it should be moved to another thread
new ScriptoriaWorker('scriptoria');
new ScriptoriaWorker('default recurring');
new ScriptoriaWorker(queues.QueueName.Scriptoria);
new ScriptoriaWorker(queues.QueueName.DefaultRecurring);

const serverAdapter = new ExpressAdapter();
serverAdapter.setBasePath('/admin/jobs');
Expand Down

0 comments on commit 4616cba

Please sign in to comment.