-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[New platform] Introduce start phase for core services on server #35297
Conversation
85d85ae
to
fad9a06
Compare
|
||
await root.setup(); | ||
const { http } = await root.setup(); | ||
http.registerRouter(router); |
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.
maybe it seems redundant to call both methods to run a test server. that was done to support such cases without introducing a lot of changes.
I believe we can easily to fix this later. For example, we can extend KbnTestServer
in a way it creates root
, declares all routes and after starts a real server.
💔 Build Failed |
💚 Build Succeeded |
Pinging @elastic/kibana-platform |
src/core/server/http/http_server.ts
Outdated
const serverOptions = getServerOptions(config); | ||
this.server = createServer(serverOptions); | ||
|
||
return { | ||
options: serverOptions, |
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.
deepFreeze
might be a good idea here
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.
aah yeah. I wanted to add freeze here, but found that we have 2 implementations - one for js in x-pack/secuirty
, one for ts in core/public/utils
. I think it makes sense to reach an agreement how we going to distribute environment agnostic code snippets, case with deepFreeze
is perfect example. Do we have such agreement? If not I will create a discussion
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 do not think that we do have a guideline on sharing code other than things that live as @kbn/
packages. Could make sense to move this utility there, but it's so small, I'm not sure the boilerplate of a separate package is worth it.
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.
turned out the correct implementation is not so simple microsoft/TypeScript#13923
for now I will copy this functionality, but we need to extract it in a separate package later
💚 Build Succeeded |
to get rid of Optional<HttpServer> type and make it Require<HttpServer>
💔 Build Failed |
💚 Build Succeeded |
💚 Build Succeeded |
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 really good, really just one small comment.
When you add this to the PluginsService in the follow up PR, do you also plan to introduce this to the plugin spec themselves at the same time? I'm asking because I've already added the start
lifecycle event to UI plugins.
src/core/server/http/http_server.ts
Outdated
const serverOptions = getServerOptions(config); | ||
this.server = createServer(serverOptions); | ||
|
||
return { | ||
options: serverOptions, |
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 do not think that we do have a guideline on sharing code other than things that live as @kbn/
packages. Could make sense to move this utility there, but it's so small, I'm not sure the boilerplate of a separate package is worth it.
agree, I will add it for parity. |
…ent side" This reverts commit c04fdd2.
💚 Build Succeeded |
…stic#35297) * introduce start phase. setup is bloated with start functionality * fix amp typings: server is part of start contract now * update mock files * root.start(): necessary to run test server * expose setup&start server api to simplify testing * move tests to the new API * test servers also should call root.start() * update docs * update snapshots: this functionality is tested in http server * split setup/start phases * update docs * expose http server if it not started to get rid of Optional<HttpServer> type and make it Require<HttpServer> * adopt test to exposed Http server via SetupContract * udpate docs * cleanup apm changees * check legacy service setup before start * check http server setup before start * restrict server options mutation; unify Promise interface for setup * introduce start pahse for plugins service for parity with client side * Revert "introduce start pahse for plugins service for parity with client side" This reverts commit c04fdd2.
) (#35791) * introduce start phase. setup is bloated with start functionality * fix amp typings: server is part of start contract now * update mock files * root.start(): necessary to run test server * expose setup&start server api to simplify testing * move tests to the new API * test servers also should call root.start() * update docs * update snapshots: this functionality is tested in http server * split setup/start phases * update docs * expose http server if it not started to get rid of Optional<HttpServer> type and make it Require<HttpServer> * adopt test to exposed Http server via SetupContract * udpate docs * cleanup apm changees * check legacy service setup before start * check http server setup before start * restrict server options mutation; unify Promise interface for setup * introduce start pahse for plugins service for parity with client side * Revert "introduce start pahse for plugins service for parity with client side" This reverts commit c04fdd2.
Summary
The main reason for pushing start phase on the server side is exposing an ability to register a router in New platform.
I added a full support for
start
method only for http, legacy & plugins services and changed their API accordingly.Now HTTP service exposed
Legacy service stores passed setup contracts and create an instance of KbnServer on start
Other core services expose start method, but it is just noop.
Remaining core services can be updated in following PR:
plugin service - after Introducestart
lifecycle event to client #35269Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.[ ] This was checked for cross-browser compatibility, including a check against IE11[ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support[ ] Documentation was added for features that require explanation or tutorials[ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers