-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Uptime] Shim server for new platform #44938
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
[Uptime] Shim server for new platform #44938
Conversation
|
Pinging @elastic/uptime |
💔 Build Failed |
ae54462 to
7ad44f3
Compare
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
rudolf
left a comment
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.
There's a few places where your shim could be using the real NP API's already, but otherwise this is a good start.
| elasticsearch, | ||
| usageCollector: server.usage, | ||
| xpack: xpack_main, | ||
| route: (arg: any) => server.route(arg), |
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.
Not critical as a first step, but at some point it would be good to switch to using the real NP core router inside your shim. You can use server.newPlatform.setup.core.http.createRouter().
| initServerWithKibana(server); | ||
| const initializerContext = {} as PluginInitializerContext; | ||
| const { elasticsearch, xpack_main } = server.plugins; | ||
| plugin(initializerContext).setup({ |
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 signature for setup is setup(core, plugins) with all plugin dependencies being passed in as the second argument. Usage collector will be exposed from the telemetry plugin and xpack licencing is available as a NP plugin. So it would be a bit more accurate to move these dependencies into a second argument.
| init(server: KibanaServer) { | ||
| initServerWithKibana(server); | ||
| const initializerContext = {} as PluginInitializerContext; | ||
| const { elasticsearch, xpack_main } = server.plugins; |
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.
optional: you can also use the NP elasticsearch client by taking it from server.newPlatform.setup.core.elasticsearch
x-pack/legacy/plugins/uptime/server/lib/adapters/framework/adapter_types.ts
Outdated
Show resolved
Hide resolved
| } | ||
| }, | ||
| plugin: uptimeGraphQLHapiPlugin, | ||
| method: ['get', 'post'], |
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.
This is a useful example for other teams for how to replace the hapi plugin. When you switch to using the NP router in your shim (from server.newPlatform.setup.core.http.createRouter()) you won't be able to define one route with two methods (get & post) so this will have to be split into two routes.
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
|
@elasticmachine merge upstream |
rudolf
left a comment
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.
This is a good first pass at shimming the NP 👍
Next up I would suggest starting to consume the NP API's for elasticsearch and the http router
|
@elasticmachine merge upstream |
💔 Build Failed |
|
@elasticmachine merge upstream |
💚 Build Succeeded |
* WIP, trying things. * Delete call to hapi register function, use route for bootstrapping GQL. * Add files to use for new platform shim. * Add server shim. * Update mock in test file to conform to new shim interface. * Delete unneeded import and var declaration. * Fix broken type files. * Add plugin shim initializer to app bootstrapper. * Extract plugins to separate param for shim. * Rename interface and update tests. * Delete unneeded file.
* WIP, trying things. * Delete call to hapi register function, use route for bootstrapping GQL. * Add files to use for new platform shim. * Add server shim. * Update mock in test file to conform to new shim interface. * Delete unneeded import and var declaration. * Fix broken type files. * Add plugin shim initializer to app bootstrapper. * Extract plugins to separate param for shim. * Rename interface and update tests. * Delete unneeded file.
Summary
Working on shimming the Uptime server for the new platform. Code is WIP.
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.For maintainers