Skip to content

Commit

Permalink
Moves queue concurrency to parameter (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
pushchris authored Oct 2, 2023
1 parent ec692ea commit edab210
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions apps/platform/src/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default (type?: EnvType): Env => {
host: process.env.REDIS_HOST!,
port: parseInt(process.env.REDIS_PORT!),
tls: process.env.REDIS_TLS === 'true',
concurrency: parseInt(process.env.REDIS_CONCURRENCY ?? '10'),
}),
}),
storage: driver<StorageConfig>(process.env.STORAGE_DRIVER ?? 'local', {
Expand Down
7 changes: 5 additions & 2 deletions apps/platform/src/queue/RedisQueueProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { DefaultRedis, Redis, RedisConfig } from '../config/redis'

export interface RedisQueueConfig extends QueueTypeConfig, RedisConfig {
driver: 'redis'
concurrency: number
}

export default class RedisQueueProvider implements QueueProvider {
Expand All @@ -17,11 +18,13 @@ export default class RedisQueueProvider implements QueueProvider {
queue: Queue
bull: BullQueue
worker?: Worker
concurrency: number
batchSize = 40 as const
queueName = 'parcelvoy' as const

constructor(config: RedisQueueConfig, queue: Queue) {
constructor({ concurrency, ...config }: RedisQueueConfig, queue: Queue) {
this.queue = queue
this.concurrency = concurrency
this.redis = DefaultRedis(config, {
maxRetriesPerRequest: null,
})
Expand Down Expand Up @@ -98,7 +101,7 @@ export default class RedisQueueProvider implements QueueProvider {
})
}, {
connection: this.redis,
concurrency: this.batchSize,
concurrency: this.concurrency,
metrics: {
maxDataPoints: MetricsTime.TWO_WEEKS,
},
Expand Down

0 comments on commit edab210

Please sign in to comment.