Skip to content

Commit

Permalink
feat(medusa): Allow configuring of staged job polling batch size (#6333)
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl authored Feb 7, 2024
1 parent 44470bf commit 82c728b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/odd-keys-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/medusa": patch
"@medusajs/types": patch
---

feat(medusa): Allow configuring of staged job polling batch size
4 changes: 2 additions & 2 deletions packages/medusa/src/services/event-bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class EventBusService

constructor(
{ stagedJobService, logger }: InjectedDependencies,
config,
config: ConfigModule,
isSingleton = true
) {
// eslint-disable-next-line prefer-rest-params
Expand Down Expand Up @@ -201,7 +201,7 @@ export default class EventBusService
const listConfig = {
relations: [],
skip: 0,
take: 1000,
take: this.config_.projectConfig.jobs_batch_size ?? 1000,
}

while (this.shouldEnqueuerRun) {
Expand Down
16 changes: 16 additions & 0 deletions packages/types/src/common/config-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,22 @@ export type ProjectConfigOptions = {
* ```
*/
http_compression?: HttpCompressionOptions

/**
* Configure the number of staged jobs that are polled from the database. Default is 1000.
*
* @example
* ```js title="medusa-config.js"
* module.exports = {
* projectConfig: {
* jobs_batch_size: 100
* // ...
* },
* // ...
* }
* ```
*/
jobs_batch_size?: number
}

/**
Expand Down

0 comments on commit 82c728b

Please sign in to comment.