repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
docs: update changelog entries
[poolifier.git]
/
src
/
pools
/
pool.ts
diff --git
a/src/pools/pool.ts
b/src/pools/pool.ts
index 8a5e505f4f2d23909db36ef3d66e987eee9e9afd..3c660031fb90b233bb93125331c81e53200b6803 100644
(file)
--- a/
src/pools/pool.ts
+++ b/
src/pools/pool.ts
@@
-4,14
+4,30
@@
import type {
ExitHandler,
MessageHandler,
OnlineHandler
ExitHandler,
MessageHandler,
OnlineHandler
-} from './pool-worker'
-import type { WorkerChoiceStrategy } from './selection-strategies/selection-strategies-types'
+} from './worker'
+import type {
+ WorkerChoiceStrategy,
+ WorkerChoiceStrategyOptions
+} from './selection-strategies/selection-strategies-types'
/**
* Pool events emitter.
*/
export class PoolEmitter extends EventEmitter {}
/**
* Pool events emitter.
*/
export class PoolEmitter extends EventEmitter {}
+/**
+ * Enumeration of pool events.
+ */
+export const PoolEvents = Object.freeze({
+ full: 'full',
+ busy: 'busy'
+} as const)
+
+/**
+ * Pool event.
+ */
+export type PoolEvent = keyof typeof PoolEvents
+
/**
* Options for a poolifier pool.
*/
/**
* Options for a poolifier pool.
*/
@@
-36,12
+52,23
@@
export interface PoolOptions<Worker> {
* The worker choice strategy to use in this pool.
*/
workerChoiceStrategy?: WorkerChoiceStrategy
* The worker choice strategy to use in this pool.
*/
workerChoiceStrategy?: WorkerChoiceStrategy
+ /**
+ * The worker choice strategy options.
+ */
+ workerChoiceStrategyOptions?: WorkerChoiceStrategyOptions
/**
* Pool events emission.
*
* @defaultValue true
*/
enableEvents?: boolean
/**
* Pool events emission.
*
* @defaultValue true
*/
enableEvents?: boolean
+ /**
+ * Pool worker tasks queue.
+ *
+ * @experimental
+ * @defaultValue false
+ */
+ enableTasksQueue?: boolean
}
/**
}
/**
@@
-56,7
+83,8
@@
export interface IPool<Data = unknown, Response = unknown> {
*
* Events that can currently be listened to:
*
*
* Events that can currently be listened to:
*
- * - `'busy'`
+ * - `'full'`: Emitted when the pool is dynamic and full.
+ * - `'busy'`: Emitted when the pool is busy.
*/
readonly emitter?: PoolEmitter
/**
*/
readonly emitter?: PoolEmitter
/**