forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
add default client module, more wrapper methods #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
chrisdavies
merged 14 commits into
chrisdavies:alerting/task-scheduler
from
tsullivan:alerting/task-scheduler-return-taskdoc-to-caller
Sep 13, 2018
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b893db7
return raw task doc fields for calling code
tsullivan da4f53c
remove todo comment
tsullivan 3a7a5c2
helper module for default client
tsullivan 7482c0d
fix misidentified field name
tsullivan 48487b5
fix rest args warning
tsullivan b89cc9e
return raw task doc fields for calling code
tsullivan 3469f72
remove todo comment
tsullivan 8b407bb
helper module for default client
tsullivan 30d5684
fix rest args warning
tsullivan 85e6c8e
typescript fixes
tsullivan 7c6a956
Merge branch chrisdavies/alerting/task-scheduler into alerting/task-s…
tsullivan edc5852
roll back setClient takes a callback
tsullivan 6ad9282
createTaskRunner returns an object with run/cancel functions
tsullivan 6893e56
Merge branch 'my-chrisdavies/alerting/task-scheduler' into alerting/t…
tsullivan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* | ||
| * Licensed to Elasticsearch B.V. under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch B.V. licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import { fillPool } from './fill_pool'; | ||
| import { TaskManagerLogger } from './logger'; | ||
| import { ConcreteTaskInstance, SanitizedTaskDefinition, TaskDictionary } from './task'; | ||
| import { TaskManager } from './task_manager'; | ||
| import { TaskPoller } from './task_poller'; | ||
| import { TaskPool } from './task_pool'; | ||
| import { TaskManagerRunner } from './task_runner'; | ||
| import { TaskStore } from './task_store'; | ||
|
|
||
| export async function getDefaultClient( | ||
| kbnServer: any, | ||
| server: any, | ||
| config: any, | ||
| logger: TaskManagerLogger, | ||
| maxWorkers: number, | ||
| definitions: TaskDictionary<SanitizedTaskDefinition> | ||
| ): Promise<TaskManager> { | ||
| const callCluster = server.plugins.elasticsearch.getCluster('admin').callWithInternalUser; | ||
| const store = new TaskStore({ | ||
| index: config.get('taskManager.index'), | ||
| callCluster, | ||
| maxAttempts: config.get('taskManager.max_attempts'), | ||
| supportedTypes: Object.keys(definitions), | ||
| }); | ||
|
|
||
| logger.debug('Initializing the task manager index'); | ||
| await store.init(); | ||
|
|
||
| const pool = new TaskPool({ | ||
| logger, | ||
| maxWorkers, | ||
| }); | ||
|
|
||
| const contextProvider = async (taskInstance: ConcreteTaskInstance) => ({ | ||
| callCluster, | ||
| kbnServer, | ||
| taskInstance, | ||
| }); | ||
|
|
||
| const poller = new TaskPoller({ | ||
| logger, | ||
| pollInterval: config.get('taskManager.poll_interval'), | ||
| work: () => | ||
| fillPool( | ||
| pool.run, | ||
| store.fetchAvailableTasks, | ||
| (instance: ConcreteTaskInstance) => | ||
| new TaskManagerRunner({ | ||
| logger, | ||
| definition: definitions[instance.taskType], | ||
| instance, | ||
| store, | ||
| contextProvider, | ||
| }) | ||
| ), | ||
| }); | ||
|
|
||
| poller.start(); | ||
|
|
||
| return new TaskManager({ store, poller }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this to the default client, and reordered the fields to be in the order that TaskManagerRunner defines. VS Code was giving a warning about this before & after I touched it