Skip to content

[7.x] [Task Manager] Adds runNow api to Task Manager (#51601)#53120

Merged
gmmorris merged 1 commit intoelastic:7.xfrom
gmmorris:backport/7.x/pr-51601
Dec 16, 2019
Merged

[7.x] [Task Manager] Adds runNow api to Task Manager (#51601)#53120
gmmorris merged 1 commit intoelastic:7.xfrom
gmmorris:backport/7.x/pr-51601

Conversation

@gmmorris
Copy link
Copy Markdown
Contributor

Backports the following commits to 7.x:

Adds a `runNow` api to Task Manager, allowing us to force the refresh of a recurring task.

This PR includes a couple of sustainability changes as well as the feature itself.

1. **Declarative query composition.** At the moment the queries in the TaskStore are huge JSON objects that are hard to maintain and understand. This PR introduces a pattern where the different parts of the query are composed out of type-checked functions, making it easier to maintain and to construct dynamically as needs change. _This was included in this PR as the **markAvailableTasksAsClaimed** query needs different query clauses depending on whether there are specific Tasks we wish to claim first.

2. **Refactoring of the Task Poller** As the `runNow` api is introduced we find Task Manager's lifecycle in a weird state where it has both a _pull_ model, where timeouts & callbacks interact without having to responsd to any external requests, and a _push_ model where requests are made to the new `runNow` api. Balancing these two proved error prone, hard to maintain and had the potential of _lossy_ behaviour where requests are dropped accidentally. To address this TaskPoller has been refactored using Rxjs observables, remodelling the existing _pull_ mechanism as a _push_ mechanism so Task Manager can _respond_ to both _polling_ calls and _runNow_ in a similar fashion.

And ofcourse the main feature of this PR:

3. **runNow api** An api on TaskManager that takes a _task ID_ and attempts to run the task. The call returns a promise which resolves with a result which notifies the caller when the task has either completed successfully, or result in an error.
@gmmorris gmmorris added the backport This PR is a backport of another PR label Dec 16, 2019
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@gmmorris gmmorris merged commit 21f2bab into elastic:7.x Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants