-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Response Ops][Reporting] Scheduled Reports - Task (merging into feature branch) #219770
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
Changes from all commits
a74e49d
6163f7e
20ecece
c29a08e
de20db1
65f0960
2dde5f6
717cadb
72b108e
38e69ef
c9e71ba
5f6fad9
d05d9c8
4a04b90
249f14c
4c60d8e
4a14142
4ec1bca
1275f1e
8aff2c9
04b70a2
c9547ae
850ec64
10c40e5
af75dfb
95cf333
d5227aa
2a1482e
372d4c7
62fe072
0f0685e
cc65fd5
11053d1
23d837d
bbabb1f
f5bb665
5375fd2
f039e51
e75e796
c7e0fdc
424d733
0514306
fd55806
d42d1bd
214fcd5
5019e54
5ee4309
2d6dfab
b2d9bbd
8caeb79
7a0d9c5
64cfb78
b98f26c
3fd59a1
0370162
ed0a7c0
e47833c
0277de9
b0ce938
2e48fe2
530ac2c
cec4e50
a0cff7a
e770dce
626cf01
fbb3f85
f361058
7099229
a0e3fc9
baa41cb
2947bcc
3afe5b2
dc96d64
c1884f3
5398116
5a800d5
9cd5011
8faaf40
aaf4309
5c55c02
fc2b386
4fed516
d1104e4
c9911fa
85cb015
e811ec2
d18fcaf
0253ced
590e659
3834eaf
c7e26f0
8455d3c
1e3d3e9
bbea405
4df59d0
17bdcd0
4a4e0c5
e20f1bf
402ef5c
d5799f5
bfef31b
8cc0976
03c8304
2bd0d5d
d0da6b4
9a7bda6
6a7b62e
99f186c
601fbc6
bc09318
ea37895
d87b6f1
def242b
4ca09af
f3efd5a
4750222
d60bbff
3955376
5a2c076
1f46d45
a3ed61d
d95012c
035d994
ad65b91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,12 @@ import type { ReportingSetup } from '.'; | |
| import { createConfig } from './config'; | ||
| import { reportingEventLoggerFactory } from './lib/event_logger/logger'; | ||
| import type { IReport, ReportingStore } from './lib/store'; | ||
| import { ExecuteReportTask, ReportTaskParams } from './lib/tasks'; | ||
| import { | ||
| RunSingleReportTask, | ||
| ReportTaskParams, | ||
| RunScheduledReportTask, | ||
| ScheduledReportTaskParamsWithoutSpaceId, | ||
| } from './lib/tasks'; | ||
| import type { ReportingPluginRouter } from './types'; | ||
| import { EventTracker } from './usage'; | ||
| import { SCHEDULED_REPORT_SAVED_OBJECT_TYPE } from './saved_objects'; | ||
|
|
@@ -100,7 +105,8 @@ export class ReportingCore { | |
| private pluginStartDeps?: ReportingInternalStart; | ||
| private readonly pluginSetup$ = new Rx.ReplaySubject<boolean>(); // observe async background setupDeps each are done | ||
| private readonly pluginStart$ = new Rx.ReplaySubject<ReportingInternalStart>(); // observe async background startDeps | ||
| private executeTask: ExecuteReportTask; | ||
| private runSingleReportTask: RunSingleReportTask; | ||
| private runScheduledReportTask: RunScheduledReportTask; | ||
| private config: ReportingConfigType; | ||
| private executing: Set<string>; | ||
| private exportTypesRegistry = new ExportTypesRegistry(); | ||
|
|
@@ -121,7 +127,16 @@ export class ReportingCore { | |
| this.getExportTypes().forEach((et) => { | ||
| this.exportTypesRegistry.register(et); | ||
| }); | ||
| this.executeTask = new ExecuteReportTask(this, config, this.logger); | ||
| this.runSingleReportTask = new RunSingleReportTask({ | ||
| reporting: this, | ||
| config, | ||
| logger: this.logger, | ||
| }); | ||
| this.runScheduledReportTask = new RunScheduledReportTask({ | ||
| reporting: this, | ||
| config, | ||
| logger: this.logger, | ||
| }); | ||
|
|
||
| this.getContract = () => ({ | ||
| registerExportTypes: (id) => id, | ||
|
|
@@ -146,9 +161,10 @@ export class ReportingCore { | |
| et.setup(setupDeps); | ||
| }); | ||
|
|
||
| const { executeTask } = this; | ||
| const { runSingleReportTask, runScheduledReportTask } = this; | ||
| setupDeps.taskManager.registerTaskDefinitions({ | ||
| [executeTask.TYPE]: executeTask.getTaskDefinition(), | ||
| [runSingleReportTask.TYPE]: runSingleReportTask.getTaskDefinition(), | ||
| [runScheduledReportTask.TYPE]: runScheduledReportTask.getTaskDefinition(), | ||
| }); | ||
| } | ||
|
|
||
|
|
@@ -164,9 +180,12 @@ export class ReportingCore { | |
| }); | ||
|
|
||
| const { taskManager } = startDeps; | ||
| const { executeTask } = this; | ||
| const { runSingleReportTask, runScheduledReportTask } = this; | ||
| // enable this instance to generate reports | ||
| await Promise.all([executeTask.init(taskManager)]); | ||
| await Promise.all([ | ||
| runSingleReportTask.init(taskManager), | ||
| runScheduledReportTask.init(taskManager), | ||
| ]); | ||
| } | ||
|
|
||
| public pluginStop() { | ||
|
|
@@ -326,7 +345,14 @@ export class ReportingCore { | |
| } | ||
|
|
||
| public async scheduleTask(request: KibanaRequest, report: ReportTaskParams) { | ||
| return await this.executeTask.scheduleTask(request, report); | ||
| return await this.runSingleReportTask.scheduleTask(request, report); | ||
| } | ||
|
|
||
| public async scheduleRecurringTask( | ||
| request: KibanaRequest, | ||
| report: ScheduledReportTaskParamsWithoutSpaceId | ||
| ) { | ||
| return await this.runScheduledReportTask.scheduleTask(request, report); | ||
| } | ||
|
|
||
| public async getStore() { | ||
|
|
@@ -385,13 +411,17 @@ export class ReportingCore { | |
| return dataViews; | ||
| } | ||
|
|
||
| public async getSoClient(request: KibanaRequest) { | ||
| public async getScopedSoClient(request: KibanaRequest) { | ||
| const { savedObjects } = await this.getPluginStartDeps(); | ||
| const savedObjectsClient = savedObjects.getScopedClient(request, { | ||
| return savedObjects.getScopedClient(request, { | ||
| excludedExtensions: [SECURITY_EXTENSION_ID], | ||
| includedHiddenTypes: [SCHEDULED_REPORT_SAVED_OBJECT_TYPE], | ||
| }); | ||
| return savedObjectsClient; | ||
| } | ||
|
|
||
| public async getInternalSoClient() { | ||
| const { savedObjects } = await this.getPluginStartDeps(); | ||
| return savedObjects.createInternalRepository([SCHEDULED_REPORT_SAVED_OBJECT_TYPE]); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this could be confusing in the future, since it returns either a scoped or internal client. And complicates the typing (minor concern). Would it be better to have separate methods? It seems pretty obvious to me in the code, right now ...
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Split into separate functions in ad65b91 |
||
| } | ||
|
|
||
| public async getDataService() { | ||
|
|
||
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.
Opened an Elasticsearch PR to add this field to the mapping: elastic/elasticsearch#127827