Skip to content

Commit 982bf6f

Browse files
author
Brad Vogel
authored
Merge pull request #337 from bee-queue/brad/better-example
feat: better example showing jobs move through states
2 parents 6fb9bdb + 7c0bc7c commit 982bf6f

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

example/bee.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@ async function main() {
1212
const server = new RedisServer(REDIS_SERVER_PORT);
1313
await server.open();
1414

15+
const queue = new Bee('name_of_my_queue', {
16+
redis: {
17+
port: REDIS_SERVER_PORT,
18+
},
19+
});
20+
21+
// Fake process function to move newly created jobs in the UI through a few of the job states.
22+
queue.process(async function (job) {
23+
// Wait 5sec
24+
await new Promise((res) => setTimeout(res, 5000));
25+
26+
// Randomly succeeds or fails the job to put some jobs in completed and some in failed.
27+
if (Math.random() > 0.5) {
28+
throw new Error('fake error');
29+
}
30+
});
31+
1532
Arena(
1633
{
1734
Bee,

0 commit comments

Comments
 (0)