Skip to content

add default client module, more wrapper methods#3

Merged
chrisdavies merged 14 commits intochrisdavies:alerting/task-schedulerfrom
tsullivan:alerting/task-scheduler-return-taskdoc-to-caller
Sep 13, 2018
Merged

add default client module, more wrapper methods#3
chrisdavies merged 14 commits intochrisdavies:alerting/task-schedulerfrom
tsullivan:alerting/task-scheduler-return-taskdoc-to-caller

Conversation

@tsullivan
Copy link
Copy Markdown
Collaborator

These changes give access to plugins the task ID and other information, which is needed for removing tasks and getting other info.

@tsullivan tsullivan force-pushed the alerting/task-scheduler-return-taskdoc-to-caller branch from ae3c66a to b893db7 Compare September 10, 2018 17:01
Copy link
Copy Markdown
Owner

@chrisdavies chrisdavies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM w/ tweaks, particularly validating the client in the constructor and / or setter, rather than in the points where it's consumed.

public schedule(task: TaskInstance) {
if (this.client == null) {
throw new Error('Task Manager Client has not been set properly!');
const { error } = checkClient(this.client);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of putting this check in each method, we should just have a sane default client, and put this check in any place that sets the client.

this.poller.attemptWork();
public async schedule(task: TaskInstance): Promise<RawTaskDoc> {
const result = await this.store.schedule(task);
this.poller.attemptWork(); // TODO await this?
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary to await this, as the attemptWork won't fail (it swallows / logs errors). And there's no reason to further delay the call to schedule.

@tsullivan
Copy link
Copy Markdown
Collaborator Author

validating the client in the constructor and / or setter, rather than in the points where it's consumed.

This is a great suggestion, and I addressed in 3a7a5c2

Having a helper module that constructs the default client turns out to be very helpful, I think, to see how an outside plugin (security) can construct its own client without having to do the "setup" work like scanning for task definitions and registering a logger. We talked about that need before, and I am addressing it here by making setClient take a callback function, to which it's passing some objects to.

@tsullivan
Copy link
Copy Markdown
Collaborator Author

7482c0d and 48487b5 were things I was getting from warnings in the existing code, give those a good look too.

pool.run,
store.fetchAvailableTasks,
(instance: ConcreteTaskInstance) =>
new TaskManagerRunner({
Copy link
Copy Markdown
Collaborator Author

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

@tsullivan tsullivan changed the title return raw task doc to the calling code add default client module Sep 11, 2018
@tsullivan tsullivan changed the title add default client module add default client module, more wrapper methods Sep 11, 2018
@chrisdavies chrisdavies merged commit 8cf48ff into chrisdavies:alerting/task-scheduler Sep 13, 2018
@tsullivan tsullivan deleted the alerting/task-scheduler-return-taskdoc-to-caller branch September 13, 2018 18:42
chrisdavies pushed a commit that referenced this pull request Mar 20, 2019
* Prepare control flow to use embeddable factories in add panel

* Rewrite saved object finder and add tests

* Fix usages of new saved object finder

* fix test failures

* fix some functional tests and re-introduce makeUrl

* fix tests

* remove direct hrefs in saved_object_lists

* PR review fixes

* update snapshot

* overwrite width of viz dialog

* Update src/legacy/core_plugins/kibana/public/dashboard/top_nav/add_panel.js

Co-Authored-By: flash1293 <email@johannes-reuter.de>

* Update src/legacy/core_plugins/kibana/public/discover/embeddable/search_embeddable_factory.ts

Co-Authored-By: flash1293 <email@johannes-reuter.de>

* Update src/legacy/core_plugins/kibana/public/discover/top_nav/open_search_panel.js

Co-Authored-By: flash1293 <email@johannes-reuter.de>

* Update src/legacy/core_plugins/kibana/public/visualize/wizard/search_selection/search_selection.tsx

Co-Authored-By: flash1293 <email@johannes-reuter.de>

* Update src/legacy/core_plugins/kibana/public/visualize/wizard/search_selection/search_selection.tsx

Co-Authored-By: flash1293 <email@johannes-reuter.de>

* Update src/legacy/core_plugins/kibana/public/visualize/wizard/search_selection/search_selection.tsx

Co-Authored-By: flash1293 <email@johannes-reuter.de>

* fix tests

* review fixes #1

* review fixes #2

* dont use classname in functional test

* remove call to action button prop

* align buttons correctly

* fix tests

* remove debugging statement

* Update src/legacy/core_plugins/kibana/public/dashboard/top_nav/add_panel.js

Co-Authored-By: flash1293 <email@johannes-reuter.de>

* Update src/legacy/core_plugins/kibana/public/discover/top_nav/open_search_panel.js

Co-Authored-By: flash1293 <email@johannes-reuter.de>

* review fixes #3

* improve filter behavior and enable it for search wizard

* adjust functional tests for new filter behavior

* Change translation id due to string change

* Update Jest snapshot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants