"@typescript-eslint/types": "4.15.2",
"@typescript-eslint/typescript-estree": "4.15.2",
"debug": "^4.1.1"
- },
- "dependencies": {
- "@typescript-eslint/scope-manager": {
- "version": "4.15.2",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.15.2.tgz",
- "integrity": "sha512-Zm0tf/MSKuX6aeJmuXexgdVyxT9/oJJhaCkijv0DvJVT3ui4zY6XYd6iwIo/8GEZGy43cd7w1rFMiCLHbRzAPQ==",
- "dev": true,
- "requires": {
- "@typescript-eslint/types": "4.15.2",
- "@typescript-eslint/visitor-keys": "4.15.2"
- }
- },
- "@typescript-eslint/types": {
- "version": "4.15.2",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.15.2.tgz",
- "integrity": "sha512-r7lW7HFkAarfUylJ2tKndyO9njwSyoy6cpfDKWPX6/ctZA+QyaYscAHXVAfJqtnY6aaTwDYrOhp+ginlbc7HfQ==",
- "dev": true
- },
- "@typescript-eslint/typescript-estree": {
- "version": "4.15.2",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.15.2.tgz",
- "integrity": "sha512-cGR8C2g5SPtHTQvAymEODeqx90pJHadWsgTtx6GbnTWKqsg7yp6Eaya9nFzUd4KrKhxdYTTFBiYeTPQaz/l8bw==",
- "dev": true,
- "requires": {
- "@typescript-eslint/types": "4.15.2",
- "@typescript-eslint/visitor-keys": "4.15.2",
- "debug": "^4.1.1",
- "globby": "^11.0.1",
- "is-glob": "^4.0.1",
- "semver": "^7.3.2",
- "tsutils": "^3.17.1"
- }
- },
- "@typescript-eslint/visitor-keys": {
- "version": "4.15.2",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.15.2.tgz",
- "integrity": "sha512-TME1VgSb7wTwgENN5KVj4Nqg25hP8DisXxNBojM4Nn31rYaNDIocNm5cmjOFfh42n7NVERxWrDFoETO/76ePyg==",
- "dev": true,
- "requires": {
- "@typescript-eslint/types": "4.15.2",
- "eslint-visitor-keys": "^2.0.0"
- }
- }
}
},
"@typescript-eslint/scope-manager": {
expect(WorkerChoiceStrategies.LESS_RECENTLY_USED).toBe('LESS_RECENTLY_USED')
})
- it('Verify LESS_RECENTLY_USED strategy is taken', async () => {
+ it('Verify LESS_RECENTLY_USED strategy is taken at pool creation', async () => {
const max = 3
const pool = new FixedThreadPool(
max,
'./tests/worker-files/thread/testWorker.js',
{ workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED }
)
+ expect(pool.opts.workerChoiceStrategy).toBe(
+ WorkerChoiceStrategies.LESS_RECENTLY_USED
+ )
+ // We need to clean up the resources after our test
+ await pool.destroy()
+ })
+ it('Verify LESS_RECENTLY_USED strategy can be set after pool creation', async () => {
+ const max = 3
+ const pool = new FixedThreadPool(
+ max,
+ './tests/worker-files/thread/testWorker.js'
+ )
+ pool.setWorkerChoiceStrategy(WorkerChoiceStrategies.LESS_RECENTLY_USED)
expect(pool.opts.workerChoiceStrategy).toBe(
WorkerChoiceStrategies.LESS_RECENTLY_USED
)
+ // We need to clean up the resources after our test
+ await pool.destroy()
+ })
+ it('Verify LESS_RECENTLY_USED strategy can be run in a pool', async () => {
+ const max = 3
+ const pool = new FixedThreadPool(
+ max,
+ './tests/worker-files/thread/testWorker.js',
+ { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED }
+ )
// TODO: Create a better test to cover `LessRecentlyUsedWorkerChoiceStrategy#choose`
const promises = []
for (let i = 0; i < max * 2; i++) {