-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Export Type Registry for Reporting [POC/exploration] #155081
Export Type Registry for Reporting [POC/exploration] #155081
Conversation
…le' into serverless-image-reporting-disable
…le' into serverless-image-reporting-disable
…le' into serverless-image-reporting-disable
…le' into serverless-image-reporting-disable
…le' into serverless-image-reporting-disable
…le' into serverless-image-reporting-disable
"configPath": [ | ||
"xpack", | ||
"reportingExportTypes" | ||
], |
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.
Looks like this causes the server to crash, since there are no plugins that export a config schema with this path.
For now, we can re-use the configPath from reporting
:
"configPath": [ | |
"xpack", | |
"reportingExportTypes" | |
], | |
"configPath": [ | |
"xpack", | |
"reporting" | |
], |
/** | ||
* Export types to the central reporting plugin | ||
*/ | ||
type CreateFnType = CreateJobFn<any, any>; // can not specify params types because different type of params are not assignable to each other | ||
type RunFnType = any; // can not specify because ImmediateExecuteFn is not assignable to RunTaskFn | ||
const getTypeFns: Array<() => ExportTypeDefinition<CreateFnType | null, RunFnType>> = [ | ||
getTypeCsv, | ||
getTypeCsvFromSavedObject, | ||
getTypeCsvFromSavedObjectImmediate, | ||
getTypePng, | ||
getTypePngV2, | ||
getTypePrintablePdf, | ||
getTypePrintablePdfV2, | ||
]; | ||
getTypeFns.forEach((getType) => { | ||
if ( | ||
getType === getTypeCsv || | ||
getType === getTypeCsvFromSavedObject || | ||
getType === getTypeCsvFromSavedObjectImmediate | ||
) { | ||
return ( | ||
// setFieldFormats(fieldFormats), | ||
reporting.registerExportType( | ||
getType() as unknown as ExportTypeDefinition<CreateJobFn<any, any>, RunTaskFn<any>> | ||
), | ||
setFieldFormats(fieldFormats) | ||
); | ||
} else { | ||
return reporting.registerExportType( | ||
getType() as unknown as ExportTypeDefinition<CreateJobFn<any, any>, RunTaskFn<any>> | ||
); | ||
} | ||
}); |
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 think we can simplify this section, and make it more readable without the .forEach
:
/**
* Export types to the central reporting plugin
*/
reporting.registerExportType(getTypeCsv());
reporting.registerExportType(getTypeCsvFromSavedObject());
// @ts-ignore
reporting.registerExportType(getTypeCsvFromSavedObjectImmediate());
reporting.registerExportType(getTypePng());
reporting.registerExportType(getTypePngV2());
reporting.registerExportType(getTypePrintablePdf());
reporting.registerExportType(getTypePrintablePdfV2());
I put the ts-ignore
over the getTypeCsvFromSavedObjectImmediate
because the definition for that export type is a strange one. But I think it's ok to ignore the TS error for now, since we want to remove that export type: #145937
} | ||
|
||
// do nothing | ||
public start({}, {}) {} |
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.
Within this lifecycle method, we want to make the setFieldFormats
call:
public start({}, {}) {} | |
public start(_core: CoreStart, plugins: ExportTypesPluginStartDependencies) { | |
setFieldFormats(plugins.fieldFormats); | |
} |
And ExportTypesPluginStartDependencies will just be:
export interface ExportTypesPluginStartDependencies {
fieldFormats: FieldFormatsStart;
}
public getPluginSetupDeps() { | ||
if (!this.pluginSetupDeps) { | ||
throw new Error(`"pluginSetupDeps" dependencies haven't initialized yet`); | ||
} | ||
return this.pluginSetupDeps; | ||
} | ||
|
||
/* | ||
* Gives async access to the startDeps | ||
*/ | ||
public async getPluginStartDeps() { | ||
if (this.pluginStartDeps) { | ||
return this.pluginStartDeps; | ||
} | ||
|
||
return await Rx.firstValueFrom(this.pluginStart$); | ||
} |
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.
Do we just need these 2 methods from this class?
- PNGExportTypeDefinition | ||
- PDFExportTypeDefinition | ||
|
||
The `ReportingPlugin` calls the `ReportingExportTypesPlugin` and creates an instance of the `ExportTypeRegistry`. These export types use the `ReportingPlugin`'s registerExportType() within the `ExportTypeRegistry`. The `ReportingPlugin` uses the getExportType() method to use the registered export types for exporting. |
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.
The `ReportingPlugin` calls the `ReportingExportTypesPlugin` and creates an instance of the `ExportTypeRegistry`. These export types use the `ReportingPlugin`'s registerExportType() within the `ExportTypeRegistry`. The `ReportingPlugin` uses the getExportType() method to use the registered export types for exporting. | |
The `ReportingPlugin` creates an instance of the `ExportTypeRegistry` and exposes its `registerExportType()` to other plugins, which `ReportingExportTypesPlugin` uses to register all of the export types. The `ReportingPlugin` uses the getExportType() method to use the registered export types for exporting. |
@@ -31,6 +31,7 @@ export function isConfigPath(value: unknown): value is ConfigPath { | |||
* @internal | |||
*/ | |||
export interface Config { | |||
kbnConfig: any; |
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 see the confusion here. Reporting has a strange object that gets passed around from a class called ReportingConfig
. The reasons we do this go way back, but I believe that passing config around to the parts that need it might be simpler now.
Given the impact of this, I believe we should add a granular step #152845: Refactor ReportingConfig
to just use a simple type.
@rshen91 Would you mind if we put this PR on pause while we look at that?
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 think this simplifies the base code quite a lot and hopefully makes things in this PR easier: #157118.
💔 Build FailedFailed CI Steps
Test Failures
Metrics [docs]
History
To update your PR or re-run it, just comment with: cc @rshen91 |
Summary
#152845
This PR will lend itself to closing (but doesn't close this) - #154675
The different export types from
ReportingExportTypes
plugin will register themselves withinReportingPlugin
's export types registry and the registry will have the allowed export types for serverless.Checklist
Delete any items that are not applicable to this PR.