11import { ChannelConfig } from '@nestjstools/messaging' ;
2+ import { KeepJobs } from 'bullmq' ;
23
34export class RedisChannelConfig extends ChannelConfig {
45 public readonly connection : Connection ;
@@ -9,6 +10,7 @@ export class RedisChannelConfig extends ChannelConfig {
910 * Read more: https://github.com/taskforcesh/bullmq/issues/1219#issuecomment-1113903785
1011 */
1112 public readonly keyPrefix ?: string ;
13+ public readonly bullJobOptions ?: BullJobOptions ;
1214
1315 constructor ( {
1416 name,
@@ -19,6 +21,7 @@ export class RedisChannelConfig extends ChannelConfig {
1921 middlewares,
2022 normalizer,
2123 keyPrefix,
24+ bullJobOptions,
2225 } : RedisChannelConfig ) {
2326 super (
2427 name ,
@@ -30,6 +33,7 @@ export class RedisChannelConfig extends ChannelConfig {
3033 this . connection = connection ;
3134 this . queue = queue ;
3235 this . keyPrefix = keyPrefix ;
36+ this . bullJobOptions = bullJobOptions ;
3337 }
3438}
3539
@@ -39,3 +43,22 @@ interface Connection {
3943 password ?: string ;
4044 db ?: number ;
4145}
46+
47+ interface BullJobOptions {
48+ /**
49+ * If true, removes the job when it successfully completes
50+ * When given a number, it specifies the maximum amount of
51+ * jobs to keep, or you can provide an object specifying max
52+ * age and/or count to keep. It overrides whatever setting is used in the worker.
53+ * Default behavior is to keep the job in the completed set.
54+ */
55+ removeOnComplete ?: number | boolean | KeepJobs ;
56+ /**
57+ * If true, removes the job when it fails after all attempts.
58+ * When given a number, it specifies the maximum amount of
59+ * jobs to keep, or you can provide an object specifying max
60+ * age and/or count to keep. It overrides whatever setting is used in the worker.
61+ * Default behavior is to keep the job in the failed set.
62+ */
63+ removeOnFail ?: number | boolean | KeepJobs ;
64+ }
0 commit comments