[Scheduled Reports] Handling create/execute jobs with scheduling in mind #75605
Labels
discuss
Feature:Reporting:Framework
Reporting issues pertaining to the overall framework
needs-team
Issues missing a team label
ExportTypeRegistry is what provides the "create job" and "execute job" functions for each Reporting integration instance. This issue outlines how the ExportTypeRegistry will be carried over in Reporting when it uses Task Manager for queuing.
The flow of creating a reporting job has differences between "ad-hoc" reports and scheduled reports. When reports are scheduled and it is time to execute the job, Task Manager goes straight to the "Execute Job" flow.
Another difference between ad-hock and scheduled reports, is that ad-hoc reports will have a "pending" phase where they are waiting for a Kibana instance, but scheduled reports will not have that phase.
Create Job (For Ad-Hoc)
Generating a report begins with an incoming user POST request. The request body has contains a keyword field for the exportType (
payload.jobType
) for type of job, which is used by the ExportTypeRegistry to find the corresponding ExportTypeDefinition.The create job request handler (referred to as controller) gives the request ExportTypeDefinition's
schedule
function, stores the "pending" report in historical data. The controller then saves the document in the historical index and calls Task Manager to fire an ad-hocreporting:execute
task.To support only Ad-Hoc, there does not have to be much info in the parameters of the scheduled task. We would be able to just track the pending report's ID so it can be claimed and executed later. However, to support both ad-hoc and scheduled reports in the simplest way, the task parameters should have the full information about the report, including the encrypted headers.
Create Job (For Scheduled)
Creating a job for scheduled reports refers to creating the task parameters that are passed to Task Manager, and are part of the task instance context when the task runs. Task parameters for scheduled reports contain complete information about the report, plus encrypted headers: enough context to execute a reporting job from scratch each time the schedule is triggered.
A sample of task instance parameters (same for ad-hoc and scheduled):
Execute Job
The run function of the
reporting:execute
task type receives incoming tasks triggered by Task Manager, and passes the job to the corresponding ExportTypeDefinition execute job function.As mentioned above, reports will come to the same execute flow whether they are ad-hoc or scheduled, and have the full information about the report in task parameters. There will be slight differences in the flow between ad-hoc and scheduled reports:
runAt
time.interval
field can be given in the scheduling data, but we would not be able to support custom intervalsThe text was updated successfully, but these errors were encountered: