forked from novuhq/novu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request novuhq#4544 from novuhq/inf-93-environment-variabl…
…es-for-workers-configuration feat(worker): manage default workers config through env variables
- Loading branch information
Showing
14 changed files
with
233 additions
and
36 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
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 @@ | ||
export * from './workers'; |
119 changes: 119 additions & 0 deletions
119
packages/application-generic/src/config/workers.config.spec.ts
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,119 @@ | ||
import { | ||
getInboundParseMailWorkerOptions, | ||
getStandardWorkerOptions, | ||
getSubscriberProcessWorkerOptions, | ||
getWebSocketWorkerOptions, | ||
getWorkflowWorkerOptions, | ||
} from './workers'; | ||
|
||
describe('Workers Config', () => { | ||
describe('Inbound Parse Mail Worker', () => { | ||
it('should have the default values when no environment variable set', () => { | ||
expect(getInboundParseMailWorkerOptions()).toEqual({ | ||
concurrency: 200, | ||
lockDuration: 90000, | ||
}); | ||
}); | ||
|
||
it('should have the values passed through the environment variables', () => { | ||
process.env.WORKER_DEFAULT_CONCURRENCY = '100'; | ||
process.env.WORKER_DEFAULT_LOCK_DURATION = '10'; | ||
|
||
expect(getInboundParseMailWorkerOptions()).toEqual({ | ||
concurrency: 100, | ||
lockDuration: 10, | ||
}); | ||
|
||
process.env.WORKER_DEFAULT_CONCURRENCY = ''; | ||
process.env.WORKER_DEFAULT_LOCK_DURATION = ''; | ||
}); | ||
}); | ||
|
||
describe('Standard Worker', () => { | ||
it('should have the default values when no environment variable set', () => { | ||
expect(getStandardWorkerOptions()).toEqual({ | ||
concurrency: 200, | ||
lockDuration: 90000, | ||
}); | ||
}); | ||
|
||
it('should have the values passed through the environment variables', () => { | ||
process.env.WORKER_DEFAULT_CONCURRENCY = '100'; | ||
process.env.WORKER_DEFAULT_LOCK_DURATION = '10'; | ||
|
||
expect(getStandardWorkerOptions()).toEqual({ | ||
concurrency: 100, | ||
lockDuration: 10, | ||
}); | ||
|
||
process.env.WORKER_DEFAULT_CONCURRENCY = ''; | ||
process.env.WORKER_DEFAULT_LOCK_DURATION = ''; | ||
}); | ||
}); | ||
|
||
describe('Subscriber Process Worker', () => { | ||
it('should have the default values when no environment variable set', () => { | ||
expect(getSubscriberProcessWorkerOptions()).toEqual({ | ||
concurrency: 200, | ||
lockDuration: 90000, | ||
}); | ||
}); | ||
|
||
it('should have the values passed through the environment variables', () => { | ||
process.env.WORKER_DEFAULT_CONCURRENCY = '100'; | ||
process.env.WORKER_DEFAULT_LOCK_DURATION = '10'; | ||
|
||
expect(getSubscriberProcessWorkerOptions()).toEqual({ | ||
concurrency: 100, | ||
lockDuration: 10, | ||
}); | ||
|
||
process.env.WORKER_DEFAULT_CONCURRENCY = ''; | ||
process.env.WORKER_DEFAULT_LOCK_DURATION = ''; | ||
}); | ||
}); | ||
|
||
describe('Web Socket Worker', () => { | ||
it('should have the default values when no environment variable set', () => { | ||
expect(getWebSocketWorkerOptions()).toEqual({ | ||
concurrency: 200, | ||
lockDuration: 90000, | ||
}); | ||
}); | ||
|
||
it('should have the values passed through the environment variables', () => { | ||
process.env.WORKER_DEFAULT_CONCURRENCY = '100'; | ||
process.env.WORKER_DEFAULT_LOCK_DURATION = '10'; | ||
|
||
expect(getWebSocketWorkerOptions()).toEqual({ | ||
concurrency: 100, | ||
lockDuration: 10, | ||
}); | ||
|
||
process.env.WORKER_DEFAULT_CONCURRENCY = ''; | ||
process.env.WORKER_DEFAULT_LOCK_DURATION = ''; | ||
}); | ||
}); | ||
|
||
describe('Workflow Worker', () => { | ||
it('should have the default values when no environment variable set', () => { | ||
expect(getWorkflowWorkerOptions()).toEqual({ | ||
concurrency: 200, | ||
lockDuration: 90000, | ||
}); | ||
}); | ||
|
||
it('should have the values passed through the environment variables', () => { | ||
process.env.WORKER_DEFAULT_CONCURRENCY = '100'; | ||
process.env.WORKER_DEFAULT_LOCK_DURATION = '10'; | ||
|
||
expect(getWorkflowWorkerOptions()).toEqual({ | ||
concurrency: 100, | ||
lockDuration: 10, | ||
}); | ||
|
||
process.env.WORKER_DEFAULT_CONCURRENCY = ''; | ||
process.env.WORKER_DEFAULT_LOCK_DURATION = ''; | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.