-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathAbstractEnqueuedJobProcessor.ts
35 lines (33 loc) · 1.28 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
35
import {
AbstractBackgroundJobProcessorNew,
type BackgroundJobProcessorConfigNew,
type SupportedQueueIds,
} from '@lokalise/background-jobs-common'
import { CommonBullmqFactoryNew } from '@lokalise/background-jobs-common'
import type { BullmqSupportedQueues, Dependencies } from '../CommonModule.js'
import { SERVICE_NAME } from '../config.js'
type AbstractEnqueuedJobProcessorConfig<QueueId extends SupportedQueueIds<BullmqSupportedQueues>> =
Omit<BackgroundJobProcessorConfigNew<BullmqSupportedQueues, QueueId>, 'isTest' | 'redisConfig'>
export abstract class AbstractEnqueuedJobProcessor<
QueueId extends SupportedQueueIds<BullmqSupportedQueues>,
> extends AbstractBackgroundJobProcessorNew<BullmqSupportedQueues, QueueId> {
protected constructor(
dependencies: Dependencies,
config: AbstractEnqueuedJobProcessorConfig<QueueId>,
) {
super(
{
logger: dependencies.logger,
errorReporter: dependencies.errorReporter,
workerFactory: new CommonBullmqFactoryNew(),
transactionObservabilityManager: dependencies.transactionObservabilityManager,
queueManager: dependencies.bullmqQueueManager,
},
{
queueId: config.queueId,
ownerName: SERVICE_NAME,
workerOptions: config.workerOptions,
},
)
}
}