-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce --num-workers option / -j flag (#4)
This patch introduces a CLI option to limit the number of workers processes used by `igniter`. This only affects `ExecTask` tasks.
- Loading branch information
Showing
6 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,51 @@ | ||
declare module "task-pool" { | ||
export type PoolStyle = 'callback' | 'promise' | ||
|
||
export interface PoolInit { | ||
timeout: number, | ||
style: PoolStyle, | ||
limit: number, | ||
} | ||
|
||
export interface PoolTaskOptions { | ||
timeout: number, | ||
style: PoolStyle, | ||
} | ||
|
||
export type PoolTaskFunction<TArgs> = (...args: TArgs[]) => any | ||
|
||
export interface PoolTask<TFnArgs> { | ||
fn: PoolTaskFunction<TFnArgs>, | ||
timeout: number, | ||
style: PoolStyle, | ||
args: any[], | ||
on: (event: string, fn: (event: any) => void) => void, | ||
} | ||
|
||
export type PoolTaskFactory<TPoolStyle extends PoolStyle> = <TArgs>(...args: TArgs[]) => | ||
(TPoolStyle extends 'callback' ? PoolTask<TArgs> : Promise<any> & PoolTask<any>) | ||
|
||
export class Pool<TPoolStyle extends PoolStyle = 'callback'> { | ||
constructor(init: Partial<PoolInit>) | ||
|
||
timeout: Pick<PoolInit, 'timeout'> | ||
|
||
style: TPoolStyle | ||
|
||
limit: Pick<PoolInit, 'limit'> | ||
|
||
running: number | ||
|
||
queue: PoolTask<any>[] | ||
|
||
wrap(Function, options?: Partial<PoolTaskOptions>): PoolTaskFactory<TPoolStyle> | ||
|
||
next() | ||
|
||
start(): boolean | ||
|
||
add(task: PoolTask<any>) | ||
|
||
get promise(): Pool<'promise'> | ||
} | ||
} |