Skip to content

Commit 44f97e0

Browse files
intproBoris Dorofeev
andauthored
feat: add paused field to queue
* fix: change prefix discovery * fix: bull-dot-project prefix * feat: add paused field to queue * fix: failed count * refactor: according new graphql-compose syntax * fix: redis uri Co-authored-by: Boris Dorofeev <[email protected]>
1 parent dcbfcaf commit 44f97e0

22 files changed

+120
-118
lines changed

example/src/connectRedis.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Redis, { RedisOptions } from 'ioredis';
22

33
// TODO: remove get from OPTIONS
4-
const BULL_REDIS_URI = 'redis://127.0.0.1:6379';
4+
const BULL_REDIS_URI = process.env.BULL_REDIS_URI || 'redis://127.0.0.1:6379';
55

66
const redisInstances = new Map<string, Redis.Redis>();
77

example/src/demo_queues/fetchMetrics.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ const metricsWorker = new Worker(
2929
async (job) => {
3030
//https://github.com/taskforcesh/bullmq/issues/69
3131
console.log(new Date().toISOString(), 'Starting name: ' + job.name + ', job: ' + job.id);
32-
return new Promise((resolve) => {
32+
return new Promise((resolve, reject) => {
33+
//throw new Error('Ошибка обработки данных...');
34+
//setTimeout(() => reject('Здесь какая то причина ...'), 0);
3335
setTimeout(
3436
() =>
3537
resolve({

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"homepage": "https://github.com/graphql-compose/graphql-compose-bullmq",
2727
"peerDependencies": {
28-
"graphql-compose": "^7.0.4",
28+
"graphql-compose": "^7.15.0",
2929
"bullmq": "^1.8.0"
3030
},
3131
"devDependencies": {
@@ -47,7 +47,7 @@
4747
"express": "^4.17.1",
4848
"express-graphql": "^0.9.0",
4949
"graphql": "14.6.0",
50-
"graphql-compose": "7.14.0",
50+
"graphql-compose": "7.15.0",
5151
"jest": "25.2.4",
5252
"prettier": "2.0.2",
5353
"rimraf": "3.0.2",

src/mutation/jobAddBulk.ts

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function createJobAddBulkFC(
1313
type: sc.createObjectTC({
1414
name: `${typePrefix}JobAddBulkPayload`,
1515
fields: {
16-
jobs: getJobTC(sc, opts).getTypePlural(),
16+
jobs: getJobTC(sc, opts).List,
1717
},
1818
}),
1919
args: {
@@ -22,30 +22,28 @@ export function createJobAddBulkFC(
2222
defaultValue: 'bull',
2323
},
2424
queueName: 'String!',
25-
jobs: sc
26-
.createInputTC({
27-
name: `${typePrefix}JobAddInputBulk`,
28-
fields: {
29-
name: 'String!',
30-
data: 'JSON!',
31-
options: sc.createInputTC({
32-
name: `${typePrefix}JobOptionsInputBulk`,
33-
fields: {
34-
priority: 'Int',
35-
delay: 'Int',
36-
attempts: 'Int',
37-
backoff: 'JSON', // | TODO: BackoffOptions
38-
lifo: 'Boolean',
39-
timeout: 'Int',
40-
jobId: 'String',
41-
removeOnComplete: 'Boolean', //TODO: bool or int
42-
removeOnFail: 'Boolean', //TODO: bool or int
43-
stackTraceLimit: 'Int',
44-
},
45-
}),
46-
},
47-
})
48-
.getTypePlural(),
25+
jobs: sc.createInputTC({
26+
name: `${typePrefix}JobAddInputBulk`,
27+
fields: {
28+
name: 'String!',
29+
data: 'JSON!',
30+
options: sc.createInputTC({
31+
name: `${typePrefix}JobOptionsInputBulk`,
32+
fields: {
33+
priority: 'Int',
34+
delay: 'Int',
35+
attempts: 'Int',
36+
backoff: 'JSON', // | TODO: BackoffOptions
37+
lifo: 'Boolean',
38+
timeout: 'Int',
39+
jobId: 'String',
40+
removeOnComplete: 'Boolean', //TODO: bool or int
41+
removeOnFail: 'Boolean', //TODO: bool or int
42+
stackTraceLimit: 'Int',
43+
},
44+
}),
45+
},
46+
}).List,
4947
},
5048
resolve: async (_, { prefix, queueName, jobs }) => {
5149
const queue = await findQueue(prefix, queueName, opts);

src/mutation/jobAddCron.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,16 @@ export function createJobAddCronFC(
3737
removeOnComplete: 'Boolean', //TODO: bool or int
3838
removeOnFail: 'Boolean', //TODO: bool or int
3939
stackTraceLimit: 'Int',
40-
repeat: sc
41-
.createInputTC({
42-
name: `${typePrefix}JobOptionsInputRepeatCron`,
43-
fields: {
44-
tz: 'String',
45-
endDate: 'Date',
46-
limit: 'Int',
47-
cron: 'String!',
48-
startDate: 'Date',
49-
},
50-
})
51-
.getTypeNonNull(),
40+
repeat: sc.createInputTC({
41+
name: `${typePrefix}JobOptionsInputRepeatCron`,
42+
fields: {
43+
tz: 'String',
44+
endDate: 'Date',
45+
limit: 'Int',
46+
cron: 'String!',
47+
startDate: 'Date',
48+
},
49+
}).NonNull,
5250
},
5351
}),
5452
},

src/mutation/jobAddEvery.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,15 @@ export function createJobAddEveryFC(
3737
removeOnComplete: 'Boolean', //TODO: bool or int
3838
removeOnFail: 'Boolean', //TODO: bool or int
3939
stackTraceLimit: 'Int',
40-
repeat: sc
41-
.createInputTC({
42-
name: `${typePrefix}JobOptionsInputRepeatEvery`,
43-
fields: {
44-
tz: 'String',
45-
endDate: 'Date',
46-
limit: 'Int',
47-
every: 'String!',
48-
},
49-
})
50-
.getTypeNonNull(),
40+
repeat: sc.createInputTC({
41+
name: `${typePrefix}JobOptionsInputRepeatEvery`,
42+
fields: {
43+
tz: 'String',
44+
endDate: 'Date',
45+
limit: 'Int',
46+
every: 'String!',
47+
},
48+
}).NonNull,
5149
},
5250
}),
5351
},

src/query/queueKeys.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ export function createQueueKeysFC(
88
): ObjectTypeComposerFieldConfigAsObjectDefinition<any, any> {
99
const { typePrefix } = opts;
1010
return {
11-
type: sc
12-
.createObjectTC({
13-
name: `${typePrefix}QueueKeysResult`,
14-
fields: {
15-
queueName: 'String!',
16-
prefix: 'String!',
17-
},
18-
})
19-
.getTypePlural(),
11+
type: sc.createObjectTC({
12+
name: `${typePrefix}QueueKeysResult`,
13+
fields: {
14+
queueName: 'String!',
15+
prefix: 'String!',
16+
},
17+
}).List,
2018
args: {
2119
prefixGlob: {
2220
type: 'String',

src/query/queues.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function createQueuesFC(
88
opts: Options
99
): ObjectTypeComposerFieldConfigAsObjectDefinition<any, any> {
1010
return {
11-
type: getQueueTC(sc, opts).getTypeNonNull().getTypePlural(),
11+
type: getQueueTC(sc, opts).NonNull.List,
1212
args: {
1313
prefix: {
1414
type: 'String',

src/types/job/Job.opts.repeat.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,5 @@ export function createRepeatOptionsTC(sc: SchemaComposer<any>, opts: Options) {
4444
return isObject(value) && value.hasOwnProperty('cron');
4545
});
4646

47-
sc.addSchemaMustHaveType(RepeatOptionsEveryTC);
48-
sc.addSchemaMustHaveType(RepeatOptionsCronTC);
49-
5047
return RepeatOptionsInterfaceTC;
5148
}

src/types/job/JobInput.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function createJobDataITC(
1717
someTC = someTC.getInputTypeComposer();
1818
}
1919

20-
return someTC.getTypeNonNull();
20+
return someTC.NonNull;
2121
} else {
2222
return 'JSON!';
2323
}

0 commit comments

Comments
 (0)