@cloud-copilot/iam-lens
Version:
Visibility in IAM in and across AWS accounts
47 lines • 1.81 kB
TypeScript
import { type Job, type JobResult } from '@cloud-copilot/job';
/**
* A Job runner that pulls tasks from a source and executes them concurrently.
*
* This will run a fixed number of workers up to the specified concurrency.
*/
export declare class PullBasedJobRunner<T = void, P = Record<string, unknown>, TaskDetails = any> {
private concurrency;
private getNextTask;
private makeJobForTask;
private onComplete;
private isAcceptingWork;
private activeJobs;
private workers;
private idlePromise;
/**
* Creates an instance of PullBasedJobRunner.
*
* @param concurrency the number of concurrent workers to run
* @param getNextTask a function that returns the next task for a worker
* @param makeJobForTask a function that creates a job for the given task details
* @param onComplete a function that is called when a job is completed
*/
constructor(concurrency: number, getNextTask: (workerId: number) => Promise<TaskDetails | undefined>, makeJobForTask: (taskDetails: TaskDetails) => Job<T, P>, onComplete: (result: JobResult<T, P>) => Promise<void>);
/**
* Create a worker for running tasks from the queue.
*
* @param workerId the ID of the worker
* @returns A promise that resolves when the worker is done processing tasks.
*/
private worker;
/**
* Waits for work to be available in the queue.
*
* @returns A promise that resolves when new jobs are available to work on.
*/
private waitForWork;
/**
* Finish all work and shut down the workers when no further tasks are available.
*/
finishAllWork(): Promise<void>;
/**
* Notify the workers that new work is available.
*/
notifyWorkAvailable(): void;
}
//# sourceMappingURL=JobRunner.d.ts.map