Skip to content

Commit ff9934f

Browse files
committed
small refactor
1 parent 39f885b commit ff9934f

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

x-pack/plugins/task_manager/server/polling_lifecycle.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,23 @@ export class TaskPollingLifecycle {
190190
return !this.pollingSubscription.closed;
191191
}
192192

193+
private pollForWork = async (...tasksToClaim: string[]): Promise<FillPoolResult> => {
194+
return fillPool(
195+
// claim available tasks
196+
() =>
197+
claimAvailableTasks(
198+
tasksToClaim.splice(0, this.pool.availableWorkers),
199+
this.store.claimAvailableTasks,
200+
this.pool.availableWorkers,
201+
this.logger
202+
),
203+
// wrap each task in a Task Runner
204+
this.createTaskRunnerForTask,
205+
// place tasks in the Task Pool
206+
async (tasks: TaskRunner[]) => await this.pool.run(tasks)
207+
);
208+
};
209+
193210
private subscribeToPoller(poller$: Observable<Result<FillPoolResult, PollingError<string>>>) {
194211
return poller$
195212
.pipe(
@@ -209,23 +226,6 @@ export class TaskPollingLifecycle {
209226
this.emitEvent(asTaskPollingCycleEvent<string>(event));
210227
});
211228
}
212-
213-
private pollForWork = async (...tasksToClaim: string[]): Promise<FillPoolResult> => {
214-
return fillPool(
215-
// claim available tasks
216-
() =>
217-
claimAvailableTasks(
218-
tasksToClaim.splice(0, this.pool.availableWorkers),
219-
this.store.claimAvailableTasks,
220-
this.pool.availableWorkers,
221-
this.logger
222-
),
223-
// wrap each task in a Task Runner
224-
this.createTaskRunnerForTask,
225-
// place tasks in the Task Pool
226-
async (tasks: TaskRunner[]) => await this.pool.run(tasks)
227-
);
228-
};
229229
}
230230

231231
export async function claimAvailableTasks(

0 commit comments

Comments
 (0)