repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge dependabot/npm_and_yarn/examples/typescript/websocket-server-pool/ws-hybrid...
[poolifier.git]
/
src
/
pools
/
cluster
/
dynamic.ts
diff --git
a/src/pools/cluster/dynamic.ts
b/src/pools/cluster/dynamic.ts
index a9ccd6977255bcadc43bee150d8684a3ee3ad75e..51d1cbeece56d374df9228cbee9dbdfed86f1989 100644
(file)
--- a/
src/pools/cluster/dynamic.ts
+++ b/
src/pools/cluster/dynamic.ts
@@
-1,5
+1,6
@@
-import { type PoolType, PoolTypes } from '../pool'
-import { type ClusterPoolOptions, FixedClusterPool } from './fixed'
+import { PoolEvents, type PoolType, PoolTypes } from '../pool.js'
+import { checkDynamicPoolSize } from '../utils.js'
+import { type ClusterPoolOptions, FixedClusterPool } from './fixed.js'
/**
* A cluster pool with a dynamic number of workers, but a guaranteed minimum number of workers.
/**
* A cluster pool with a dynamic number of workers, but a guaranteed minimum number of workers.
@@
-26,21
+27,32
@@
export class DynamicClusterPool<
*/
public constructor (
min: number,
*/
public constructor (
min: number,
-
protected readonly
max: number,
+ max: number,
filePath: string,
opts: ClusterPoolOptions = {}
) {
filePath: string,
opts: ClusterPoolOptions = {}
) {
- super(min, filePath, opts)
+ super(min, filePath, opts, max)
+ checkDynamicPoolSize(
+ this.minimumNumberOfWorkers,
+ this.maximumNumberOfWorkers
+ )
}
/** @inheritDoc */
}
/** @inheritDoc */
- protected
get type (): PoolType
{
- return
PoolTypes.dynamic
+ protected
shallCreateDynamicWorker (): boolean
{
+ return
(!this.full && this.internalBusy()) || this.empty
}
/** @inheritDoc */
}
/** @inheritDoc */
- protected get maxSize (): number {
- return this.max
+ protected checkAndEmitDynamicWorkerCreationEvents (): void {
+ if (this.full) {
+ this.emitter?.emit(PoolEvents.full, this.info)
+ }
+ }
+
+ /** @inheritDoc */
+ protected get type (): PoolType {
+ return PoolTypes.dynamic
}
/** @inheritDoc */
}
/** @inheritDoc */