Skip to content

Commit

Permalink
small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
gmmorris committed Oct 27, 2020
1 parent 39f885b commit ff9934f
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions x-pack/plugins/task_manager/server/polling_lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,23 @@ export class TaskPollingLifecycle {
return !this.pollingSubscription.closed;
}

private pollForWork = async (...tasksToClaim: string[]): Promise<FillPoolResult> => {
return fillPool(
// claim available tasks
() =>
claimAvailableTasks(
tasksToClaim.splice(0, this.pool.availableWorkers),
this.store.claimAvailableTasks,
this.pool.availableWorkers,
this.logger
),
// wrap each task in a Task Runner
this.createTaskRunnerForTask,
// place tasks in the Task Pool
async (tasks: TaskRunner[]) => await this.pool.run(tasks)
);
};

private subscribeToPoller(poller$: Observable<Result<FillPoolResult, PollingError<string>>>) {
return poller$
.pipe(
Expand All @@ -209,23 +226,6 @@ export class TaskPollingLifecycle {
this.emitEvent(asTaskPollingCycleEvent<string>(event));
});
}

private pollForWork = async (...tasksToClaim: string[]): Promise<FillPoolResult> => {
return fillPool(
// claim available tasks
() =>
claimAvailableTasks(
tasksToClaim.splice(0, this.pool.availableWorkers),
this.store.claimAvailableTasks,
this.pool.availableWorkers,
this.logger
),
// wrap each task in a Task Runner
this.createTaskRunnerForTask,
// place tasks in the Task Pool
async (tasks: TaskRunner[]) => await this.pool.run(tasks)
);
};
}

export async function claimAvailableTasks(
Expand Down

0 comments on commit ff9934f

Please sign in to comment.