-
Notifications
You must be signed in to change notification settings - Fork 17
/
AbstractEnqueuedJobProcessor.ts
34 lines (31 loc) · 1.17 KB
/
AbstractEnqueuedJobProcessor.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import type { BackgroundJobProcessorConfig, BaseJobPayload } from '@lokalise/background-jobs-common'
import {
AbstractBackgroundJobProcessor,
CommonBullmqFactory,
} from '@lokalise/background-jobs-common'
import { SERVICE_NAME, isTest } from '../config.js'
import type { Dependencies } from '../parentDiConfig.js'
export type BackgroundJobConfig = Omit<BackgroundJobProcessorConfig, 'isTest' | 'redisConfig'>
export abstract class AbstractEnqueuedJobProcessor<
JobPayload extends object & BaseJobPayload,
JobReturn = void,
> extends AbstractBackgroundJobProcessor<JobPayload, JobReturn> {
protected constructor(dependencies: Dependencies, config: BackgroundJobConfig) {
super(
{
logger: dependencies.logger,
errorReporter: dependencies.errorReporter,
bullmqFactory: new CommonBullmqFactory(),
transactionObservabilityManager: dependencies.transactionObservabilityManager,
},
{
isTest: isTest(),
ownerName: SERVICE_NAME,
queueId: config.queueId,
queueOptions: config.queueOptions,
workerOptions: config.workerOptions,
redisConfig: dependencies.config.redis,
},
)
}
}