-
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
Async registries #65993
Comments
Moving toward async registries would also give us longer term design flexibility, and could help solve some other problems unrelated to lazy loading (like making it easier to use core.getStartServices, for example, or synchronizing client-side registry items with the server). We have talked before about some sort of common interface or registry base class, and have debated what that should look like in practice and exactly how prescriptive it should be. It is starting to feel like we should revisit this topic more seriously, especially in light of related discussions like @stacey-gammon’s thread on an enhancements pattern. Both of these could be solved with a common registry implementation. Most important here IMHO is making sure we are aligned with @elastic/kibana-platform — this is something we should all agree on, considering the registry pattern is so common in the KP. |
Would that be the prime goal / reason to switch to async registries ? I feel like
would be a important part of the decision
Can I get more details on this need or any other that the async approach may make harder/impossible to achieve?
Code splitting is something we try to achieve on parts of the code that:
For things like registries, I'm unsure code splitting is a real need, as least for the registry registration code itself, as implementation are (often) trivial and shouldn't depends on a lot of things (but this would need a service-per-service bundle analysis) If I take the Of course this would be an implementation detail of the plugins providing each individual uiActions.registerAction('ACTION_HELLO_WORLD', async () =>
(await import('./hello_world_action_lazy')).createHelloWorldAction(async () => ({
openModal: (await core.getStartServices())[0].overlays.openModal,
}))
); could be uiActions.registerAction('ACTION_HELLO_WORLD', () =>
hello_world_action.createHelloWorldAction({
openModal: core.getStartServices().then(([{overlays}]) => overlays.openModal),
})
);
hello_world_action.createHelloWorldAction = ({openModal}) => ({
id,
//...
execute: async () => {
const {execute} = await import('./hello_world_action_execute');
return execute(openModal);
}
}) So imho it all go back to the
question |
Restarting this conversation as the
The benefit of splitting at the registry level is that it would be solution agnostic. For a single use case it really wouldn't matter but the
I think this is something that we can design for. |
Thank you for contributing to this issue, however, we are closing this issue due to inactivity as part of a backlog grooming effort. If you believe this feature/bug should still be considered, please reopen with a comment. |
We want to introduce a pattern for various app-services registries that should encourage lazy loading:
We need:
sync
API on a registrysync
API support is needed for the server side to be used in migrate/extract/inject functions. A registry should integrate with PerstistableState concepts[maybe] We need to investigate a way to load registry items in a single request. We should decide if it is worth it at all.[maybe] Figure out a way how to DYNAMICALLY share code between client and server. (need for persistable state migrations)Old context
Following-up on: #64179 (comment)
We need to work on code-splitting app-arch code,
Important question since we own multiple registries, but usually don't own actual registered items:
Should we explore into direction of async registries which would enforce code-splitting practices? or should we instead pragmatically fix existing issues inside registered items code?
So 2 options:
async
registries, try to enforce lazy-loading on registry items?--or--
Exploring async registries
To explore this direction a bit I tried to make
uiActions
registry async:I went with something like this:
we could have:
and when registering an action:
#65991
The idea here that item is registered, but initialised only when it is accessed for the first time
questions / concerns :
Does it makes sense at all to approach it on registry level? Anyway only thing we could do is to make sure our apis are async, but it is up to developer who uses registry to use
import()
?Could this
LAZY_LOAD_EVERYTHING
approach cause more problems then improvements? Not clear how for example:to bundle all canvas specific expression function in one bundle
.Just having and
id
available during registration could be not enough. we'd also likely needdisplayName
, for example, to be able to display registry items in a list without loading all the dataIf we decide to go with something like this, should we have
BaseRegistry
interface which every our registry would implement. (Or base class). it could take care of caching / preloading and give common structure for all our registries?Fixing issues ad-hoc:
Example prs to give an idea how it will look like:
visTypeVega
bundle size #64749Maybe such pragmatic approach is the way to go?
We just will address left problematic places and make sure our docs / example are following best practices?
With planned work to notify about bundle size issue introduced in new prs following this best practices will become easier: #62263
The text was updated successfully, but these errors were encountered: