-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
feffcf1
commit d88902a
Showing
22 changed files
with
223 additions
and
217 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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { v4 } from 'uuid'; | ||
import { env } from 'process'; | ||
import { JobsOptions, Queue, ConnectionOptions } from 'bullmq'; | ||
|
||
const MOVE_CONTACT_QUEUE = 'MOVE_CONTACT_QUEUE'; | ||
|
||
const environment = env as unknown as { | ||
REDIS_HOST: string; | ||
REDIS_PORT: string; | ||
QUEUE_PRIVATE_KEY: string; | ||
}; | ||
|
||
export const QUEUE_PRIVATE_KEY = environment.QUEUE_PRIVATE_KEY; | ||
|
||
export const redisConnection: ConnectionOptions = { | ||
host: environment.REDIS_HOST, | ||
port: Number(environment.REDIS_PORT) | ||
}; | ||
|
||
export interface IQueue { | ||
name: string; | ||
add(jobParams: any): Promise<string>; | ||
} | ||
|
||
export interface JobParams { | ||
jobName: string; | ||
jobData: any; | ||
jobOpts?: JobsOptions; | ||
} | ||
|
||
export class BullQueue implements IQueue { | ||
public readonly name: string; | ||
public readonly bullQueue: Queue; | ||
|
||
constructor(queueName: string) { | ||
this.name = queueName; | ||
this.bullQueue = new Queue(queueName, { connection: redisConnection }); | ||
} | ||
|
||
public async add(jobParams: JobParams): Promise<string> { | ||
const jobId = v4(); | ||
const { jobName, jobData, jobOpts } = jobParams; | ||
|
||
await this.bullQueue.add(jobName, jobData, { jobId, ...jobOpts }); | ||
return jobId; | ||
} | ||
} | ||
|
||
// Create a singleton instance of QueueManager | ||
export const moveContactQueue = new BullQueue(MOVE_CONTACT_QUEUE); |
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.