Skip to content

Commit 1e928a8

Browse files
authored
feat: queue concurrency infrastructure (#1008)
1 parent f13d0cc commit 1e928a8

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

packages/adapter-bullmq-events/src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const DEFAULT_CONCURRENCY = 5
1+
export const DEFAULT_CONCURRENCY = 10
22
export const DEFAULT_ATTEMPTS = 3
33
export const DEFAULT_BACKOFF_DELAY = 2000
44
export const DEFAULT_REMOVE_ON_COMPLETE_COUNT = 1000

packages/adapter-bullmq-events/src/worker-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class WorkerManager {
6060

6161
this.addTopicSubscription(topic, id)
6262

63-
const concurrency = options?.type === 'fifo' ? FIFO_CONCURRENCY : this.config.concurrency
63+
const concurrency = options?.type === 'fifo' ? FIFO_CONCURRENCY : options?.concurrency || this.config.concurrency
6464
const attempts = options?.maxRetries != null ? options.maxRetries + 1 : this.config.defaultJobOptions.attempts
6565
const lockDuration = options?.visibilityTimeout ? options.visibilityTimeout * MILLISECONDS_PER_SECOND : undefined
6666

packages/core/src/types.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,20 @@ export type HandlerConfig = {
4141
timeout: number
4242
}
4343

44-
export type QueueConfig = {
45-
type: 'fifo' | 'standard'
46-
maxRetries: number
47-
visibilityTimeout: number
48-
delaySeconds: number
49-
}
44+
export type QueueConfig =
45+
| {
46+
type: 'fifo'
47+
maxRetries: number
48+
visibilityTimeout: number
49+
delaySeconds: number
50+
}
51+
| {
52+
type: 'standard'
53+
maxRetries: number
54+
visibilityTimeout: number
55+
delaySeconds: number
56+
concurrency?: number
57+
}
5058

5159
export type InfrastructureConfig = {
5260
handler?: Partial<HandlerConfig>

0 commit comments

Comments
 (0)