From ff9934ffb53cb098258d1a96fefe0136faf060f7 Mon Sep 17 00:00:00 2001 From: Gidi Meir Morris Date: Tue, 27 Oct 2020 17:59:25 +0000 Subject: [PATCH] small refactor --- .../task_manager/server/polling_lifecycle.ts | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/x-pack/plugins/task_manager/server/polling_lifecycle.ts b/x-pack/plugins/task_manager/server/polling_lifecycle.ts index 2bba07d0eab11..ccba750401f28 100644 --- a/x-pack/plugins/task_manager/server/polling_lifecycle.ts +++ b/x-pack/plugins/task_manager/server/polling_lifecycle.ts @@ -190,6 +190,23 @@ export class TaskPollingLifecycle { return !this.pollingSubscription.closed; } + private pollForWork = async (...tasksToClaim: string[]): Promise => { + 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>>) { return poller$ .pipe( @@ -209,23 +226,6 @@ export class TaskPollingLifecycle { this.emitEvent(asTaskPollingCycleEvent(event)); }); } - - private pollForWork = async (...tasksToClaim: string[]): Promise => { - 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(