-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(): register job ref before instatiating a provider
- Loading branch information
1 parent
246939d
commit 9f1c730
Showing
4 changed files
with
36 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { REQUEST } from '@nestjs/core'; | ||
|
||
export const JOB_DATA = REQUEST; | ||
export const JOB_REF = REQUEST; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,32 @@ | ||
import { SetMetadata } from '@nestjs/common'; | ||
import { Scope, SetMetadata } from '@nestjs/common'; | ||
import { SCOPE_OPTIONS_METADATA } from '@nestjs/common/constants'; | ||
import { BULL_MODULE_QUEUE } from '../bull.constants'; | ||
|
||
export interface ProcessorOptions { | ||
/** | ||
* Specifies the name of the queue to subscribe to. | ||
*/ | ||
name?: string; | ||
/** | ||
* Specifies the lifetime of an injected Processor. | ||
*/ | ||
scope?: Scope; | ||
} | ||
|
||
export const Processor = (queueName?: string): ClassDecorator => | ||
SetMetadata(BULL_MODULE_QUEUE, { name: queueName }); | ||
export function Processor(): ClassDecorator; | ||
export function Processor(queueName: string): ClassDecorator; | ||
export function Processor(processorOptions: ProcessorOptions): ClassDecorator; | ||
export function Processor( | ||
queueNameOrOptions?: string | ProcessorOptions, | ||
): ClassDecorator { | ||
const options = | ||
queueNameOrOptions && typeof queueNameOrOptions === 'object' | ||
? queueNameOrOptions | ||
: { name: queueNameOrOptions }; | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
return (target: Function) => { | ||
SetMetadata(SCOPE_OPTIONS_METADATA, options)(target); | ||
SetMetadata(BULL_MODULE_QUEUE, options)(target); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters