@cloud-copilot/iam-collect
Version:
Collect IAM information from AWS Accounts
41 lines • 1.19 kB
TypeScript
/**
* Represents the outcome of a job:
* - `fulfilled` with a `value` if it succeeded
* - `rejected` with a `reason` if it threw.
*/
export type JobResult<T, P> = {
status: 'fulfilled';
value: T;
properties: P;
} | {
status: 'rejected';
reason: any;
properties: P;
};
export interface JobContext {
workerId: number;
}
/**
* Represents a job that can be executed
*/
export interface Job<T = void, P = Record<string, unknown>> {
/**
* Execute the job with the given context.
*
* @param context - The context for the job execution, see @link JobContext
* @returns A promise that is resolved by the job's worker
*/
execute: (props: JobContext & {
properties: P;
}) => Promise<T>;
/**
* Properties associated with the job, useful for logging or tracking.
*/
properties: P;
}
/**
* Runs the given jobs with up to `concurrency` tasks in flight at once.
* Resolves with an array of results in the same order as the jobs.
*/
export declare function runJobs<T = void, P = Record<string, unknown>>(jobs: Job<T, P>[], concurrency: number): Promise<JobResult<T, P>[]>;
//# sourceMappingURL=jobQueue.d.ts.map