Skip to content

Commit

Permalink
(WIP) Adding Job Scheduler support for BullMQ Queues
Browse files Browse the repository at this point in the history
  • Loading branch information
lpoulin committed Nov 27, 2024
1 parent 4917821 commit 4d862b0
Show file tree
Hide file tree
Showing 36 changed files with 27,015 additions and 1,404 deletions.
32 changes: 32 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"version": "0.2.0",
"compounds": [
{
"name": "Debug",
"configurations": ["Debug API", "Debug UI"]
}
],
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug API",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/example.ts",
"runtimeExecutable": "yarn",
"runtimeArgs": ["start:dev:server"],
"outFiles": ["${workspaceFolder}/**/*.js"],
"console": "integratedTerminal"
},
{
"type": "node",
"request": "launch",
"name": "Debug UI",
"skipFiles": ["<node_internals>/**"],
"runtimeExecutable": "yarn",
"runtimeArgs": ["lerna", "run", "--stream", "--scope", "@bull-board/ui", "dev"],
"outFiles": ["${workspaceFolder}/packages/ui/dist/**/*.js"],
"console": "integratedTerminal"
}
]
}
16 changes: 16 additions & 0 deletions example.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import * as Bull from 'bull';
import Queue3 from 'bull';
import { Queue as QueueMQ, Worker, FlowProducer } from 'bullmq';
Expand Down Expand Up @@ -131,6 +132,19 @@ const run = async () => {
});
});

app.use('/add-scheduler', (req, res) => {
const title = req.query?.title?.toString() || 'ExampleJobScheduler';

exampleBullMq.upsertJobScheduler(title, {
// every 30 seconds
pattern: '*/30 * * * * *',
});

res.json({
ok: true,
});
});

const serverAdapter: any = new ExpressAdapter();
serverAdapter.setBasePath('/ui');

Expand All @@ -149,6 +163,8 @@ const run = async () => {
console.log(' curl http://localhost:3000/add?title=Example');
console.log('To populate the queue with custom options (opts), run:');
console.log(' curl http://localhost:3000/add?title=Test&opts[delay]=10');
console.log('To populate the queue with a job scheduler, run:');
console.log(' curl http://localhost:3000/add-scheduler?title=ExampleJobScheduler');
});
};

Expand Down
Loading

0 comments on commit 4d862b0

Please sign in to comment.