Skip to content
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

D/2021 09 13 async registry #111954

Closed
wants to merge 2 commits into from

Conversation

Dosant
Copy link
Contributor

@Dosant Dosant commented Sep 13, 2021

Summary

POC for #65993

Making field formatter registry async

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
fieldFormats 66 54 -12
kibanaUtils 233 234 +1
total -11

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
fieldFormats 250 117 -133
kibanaUtils 404 440 +36
total -97

Any counts in public APIs

Total count of every any typed public API. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats any for more detailed information.

id before after diff
fieldFormats 7 6 -1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fieldFormats 0.0B 57.0KB +57.0KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
fieldFormats 3 2 -1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
dashboard 327.4KB 327.5KB +36.0B
data 779.6KB 779.7KB +37.0B
fieldFormats 75.2KB 24.3KB -51.0KB
kibanaUtils 161.3KB 162.9KB +1.7KB
total -49.2KB
Unknown metric groups

API count

id before after diff
fieldFormats 288 155 -133
kibanaUtils 597 633 +36
total -97

async chunk count

id before after diff
fieldFormats 0 2 +2

References to deprecated APIs

id before after diff
dashboard 217 218 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

id: FIELD_FORMAT_IDS.DATE,
load: () => import('./converters').then((m) => m.DateFormat),
},
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the client-side we register "loader" instead of full items

@@ -52,7 +52,9 @@ export class FieldFormatsRegistry {
init(
getConfig: FieldFormatsGetConfigFn,
metaParamsOptions: FieldFormatMetaParams = {},
defaultFieldConverters: FieldFormatInstanceType[] = baseFormatters
defaultFieldConverters:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Common class has to work with both: full-field formatter registry items (for the server-side) and loaders (for the client-side)


export class FieldFormatsRegistry {
protected fieldFormats: Map<FieldFormatId, FieldFormatInstanceType> = new Map();
protected readonly fieldFormats = new KbnRegistry<FieldFormatInstanceType>();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing internal Map to KbnRegistry to store registry items and support async loading

@@ -16,7 +16,8 @@ import {
} from '../../../core/server';
import { FieldFormatsStart, FieldFormatsSetup } from './types';
import { DateFormat, DateNanosFormat } from './lib/converters';
import { baseFormatters, FieldFormatInstanceType, FieldFormatsRegistry } from '../common';
import { FieldFormatInstanceType, FieldFormatsRegistry } from '../common';
import { baseFormatters } from '../common/constants/base_formatters';
Copy link
Contributor Author

@Dosant Dosant Sep 21, 2021

Choose a reason for hiding this comment

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

Server still registers everything eagerly, but client registers only loaders

isLoaded(id: string): boolean;
}

export class KbnRegistry<
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Draft registry implementation

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