Skip to content

Commit

Permalink
[Reporting] Abstract reports storage (#106821) (#107688)
Browse files Browse the repository at this point in the history
* Add duplex content stream
* Add content stream factory
* Move report contents gathering and writing to the content stream
* Update jobs executors to use content stream instead of returning report contents
# Conflicts:
#	x-pack/plugins/reporting/server/export_types/printable_pdf/execute_job/index.test.ts
  • Loading branch information
dokmic authored Aug 4, 2021
1 parent 5052587 commit 495e3a0
Show file tree
Hide file tree
Showing 27 changed files with 604 additions and 288 deletions.
14 changes: 5 additions & 9 deletions x-pack/plugins/reporting/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface ReportDocumentHead {
_primary_term: number;
}

export interface TaskRunResult {
export interface ReportOutput {
content_type: string | null;
content: string | null;
size: number;
Expand All @@ -53,6 +53,8 @@ export interface TaskRunResult {
warnings?: string[];
}

export type TaskRunResult = Omit<ReportOutput, 'content'>;

export interface ReportSource {
/*
* Required fields: populated in enqueue_job when the request comes in to
Expand All @@ -73,7 +75,7 @@ export interface ReportSource {
/*
* `output` is only populated if the report job is completed or failed.
*/
output: TaskRunResult | null;
output: ReportOutput | null;

/*
* Optional fields: populated when the job is claimed to execute, and after
Expand Down Expand Up @@ -122,20 +124,14 @@ export type JobStatus =
| 'processing' // Report job has been claimed and is executing
| 'failed'; // Report was not successful, and all retries are done. Nothing to download.

// payload for retrieving the error message of a failed job
export interface JobContent {
content: TaskRunResult['content'];
content_type: false;
}

/*
* Info API response: to avoid unnecessary large payloads on a network, the
* report query results do not include `payload.headers` or `output.content`,
* which can be long strings of meaningless text
*/
interface ReportSimple extends Omit<ReportSource, 'payload' | 'output'> {
payload: Omit<ReportSource['payload'], 'headers'>;
output?: Omit<TaskRunResult, 'content'>; // is undefined for report jobs that are not completed
output?: Omit<ReportOutput, 'content'>; // is undefined for report jobs that are not completed
}

/*
Expand Down
Loading

0 comments on commit 495e3a0

Please sign in to comment.