Skip to content

Commit

Permalink
[New platform] Introduce start phase for core services on server (#35297
Browse files Browse the repository at this point in the history
) (#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.
  • Loading branch information
mshustov authored Apr 30, 2019
1 parent 492198b commit cdb8738
Show file tree
Hide file tree
Showing 70 changed files with 616 additions and 324 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [AuthenticationHandler](./kibana-plugin-server.authenticationhandler.md)

## AuthenticationHandler type
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [AuthToolkit](./kibana-plugin-server.authtoolkit.md) &gt; [authenticated](./kibana-plugin-server.authtoolkit.authenticated.md)

## AuthToolkit.authenticated property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [AuthToolkit](./kibana-plugin-server.authtoolkit.md)

## AuthToolkit interface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [AuthToolkit](./kibana-plugin-server.authtoolkit.md) &gt; [redirected](./kibana-plugin-server.authtoolkit.redirected.md)

## AuthToolkit.redirected property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [AuthToolkit](./kibana-plugin-server.authtoolkit.md) &gt; [rejected](./kibana-plugin-server.authtoolkit.rejected.md)

## AuthToolkit.rejected property
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [CoreStart](./kibana-plugin-server.corestart.md) &gt; [http](./kibana-plugin-server.corestart.http.md)

## CoreStart.http property

<b>Signature:</b>

```typescript
http: HttpServiceStart;
```
18 changes: 18 additions & 0 deletions docs/development/core/server/kibana-plugin-server.corestart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [CoreStart](./kibana-plugin-server.corestart.md)

## CoreStart interface

<b>Signature:</b>

```typescript
export interface CoreStart
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [http](./kibana-plugin-server.corestart.http.md) | <code>HttpServiceStart</code> | |

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md)

## HttpServiceSetup type
Expand All @@ -6,5 +8,5 @@
<b>Signature:</b>

```typescript
export declare type HttpServiceSetup = HttpServerInfo;
export declare type HttpServiceSetup = HttpServerSetup;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [HttpServiceStart](./kibana-plugin-server.httpservicestart.md) &gt; [isListening](./kibana-plugin-server.httpservicestart.islistening.md)

## HttpServiceStart.isListening property

Indicates if http server is listening on a port

<b>Signature:</b>

```typescript
isListening: () => boolean;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [HttpServiceStart](./kibana-plugin-server.httpservicestart.md)

## HttpServiceStart interface


<b>Signature:</b>

```typescript
export interface HttpServiceStart
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [isListening](./kibana-plugin-server.httpservicestart.islistening.md) | <code>() =&gt; boolean</code> | Indicates if http server is listening on a port |

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [KibanaRequest](./kibana-plugin-server.kibanarequest.md) &gt; [body](./kibana-plugin-server.kibanarequest.body.md)

## KibanaRequest.body property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [KibanaRequest](./kibana-plugin-server.kibanarequest.md) &gt; [from](./kibana-plugin-server.kibanarequest.from.md)

## KibanaRequest.from() method
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [KibanaRequest](./kibana-plugin-server.kibanarequest.md) &gt; [getFilteredHeaders](./kibana-plugin-server.kibanarequest.getfilteredheaders.md)

## KibanaRequest.getFilteredHeaders() method
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [KibanaRequest](./kibana-plugin-server.kibanarequest.md) &gt; [headers](./kibana-plugin-server.kibanarequest.headers.md)

## KibanaRequest.headers property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [KibanaRequest](./kibana-plugin-server.kibanarequest.md)

## KibanaRequest class
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [KibanaRequest](./kibana-plugin-server.kibanarequest.md) &gt; [params](./kibana-plugin-server.kibanarequest.params.md)

## KibanaRequest.params property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [KibanaRequest](./kibana-plugin-server.kibanarequest.md) &gt; [path](./kibana-plugin-server.kibanarequest.path.md)

## KibanaRequest.path property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [KibanaRequest](./kibana-plugin-server.kibanarequest.md) &gt; [query](./kibana-plugin-server.kibanarequest.query.md)

## KibanaRequest.query property
Expand Down
2 changes: 2 additions & 0 deletions docs/development/core/server/kibana-plugin-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
| [AuthToolkit](./kibana-plugin-server.authtoolkit.md) | A tool set defining an outcome of Auth interceptor for incoming request. |
| [CallAPIOptions](./kibana-plugin-server.callapioptions.md) | The set of options that defines how API call should be made and result be processed. |
| [CoreSetup](./kibana-plugin-server.coresetup.md) | |
| [CoreStart](./kibana-plugin-server.corestart.md) | |
| [ElasticsearchServiceSetup](./kibana-plugin-server.elasticsearchservicesetup.md) | |
| [HttpServiceStart](./kibana-plugin-server.httpservicestart.md) | |
| [Logger](./kibana-plugin-server.logger.md) | Logger exposes all the necessary methods to log any type of information and this is the interface used by the logging consumers including plugins. |
| [LoggerFactory](./kibana-plugin-server.loggerfactory.md) | The single purpose of <code>LoggerFactory</code> interface is to define a way to retrieve a context-based logger instance. |
| [LogMeta](./kibana-plugin-server.logmeta.md) | Contextual metadata |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [OnRequestHandler](./kibana-plugin-server.onrequesthandler.md)

## OnRequestHandler type
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [OnRequestToolkit](./kibana-plugin-server.onrequesttoolkit.md)

## OnRequestToolkit interface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [OnRequestToolkit](./kibana-plugin-server.onrequesttoolkit.md) &gt; [next](./kibana-plugin-server.onrequesttoolkit.next.md)

## OnRequestToolkit.next property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [OnRequestToolkit](./kibana-plugin-server.onrequesttoolkit.md) &gt; [redirected](./kibana-plugin-server.onrequesttoolkit.redirected.md)

## OnRequestToolkit.redirected property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [OnRequestToolkit](./kibana-plugin-server.onrequesttoolkit.md) &gt; [rejected](./kibana-plugin-server.onrequesttoolkit.rejected.md)

## OnRequestToolkit.rejected property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [PluginSetupContext](./kibana-plugin-server.pluginsetupcontext.md) &gt; [http](./kibana-plugin-server.pluginsetupcontext.http.md)

## PluginSetupContext.http property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [Router](./kibana-plugin-server.router.md) &gt; [delete](./kibana-plugin-server.router.delete.md)

## Router.delete() method
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [Router](./kibana-plugin-server.router.md) &gt; [get](./kibana-plugin-server.router.get.md)

## Router.get() method
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [Router](./kibana-plugin-server.router.md) &gt; [getRoutes](./kibana-plugin-server.router.getroutes.md)

## Router.getRoutes() method
Expand Down
2 changes: 2 additions & 0 deletions docs/development/core/server/kibana-plugin-server.router.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [Router](./kibana-plugin-server.router.md)

## Router class
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [Router](./kibana-plugin-server.router.md) &gt; [path](./kibana-plugin-server.router.path.md)

## Router.path property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [Router](./kibana-plugin-server.router.md) &gt; [post](./kibana-plugin-server.router.post.md)

## Router.post() method
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [Router](./kibana-plugin-server.router.md) &gt; [put](./kibana-plugin-server.router.put.md)

## Router.put() method
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [Router](./kibana-plugin-server.router.md) &gt; [routes](./kibana-plugin-server.router.routes.md)

## Router.routes property
Expand Down
5 changes: 4 additions & 1 deletion src/core/public/plugins/plugins_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ export type PluginsServiceStartDeps = CoreStart;
export interface PluginsServiceSetup {
contracts: Map<string, unknown>;
}
export interface PluginsServiceStart {
contracts: Map<string, unknown>;
}

/**
* Service responsible for loading plugin bundles, initializing plugins, and managing the lifecycle
* of all plugins.
*
* @internal
*/
export class PluginsService implements CoreService<PluginsServiceSetup> {
export class PluginsService implements CoreService<PluginsServiceSetup, PluginsServiceStart> {
/** Plugin wrappers in topological order. */
private readonly plugins: Map<
PluginName,
Expand Down
1 change: 1 addition & 0 deletions src/core/server/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export async function bootstrap({

try {
await root.setup();
await root.start();
} catch (err) {
await shutdown(err);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type ElasticsearchServiceContract = PublicMethodsOf<ElasticsearchService>;
const createMock = () => {
const mocked: jest.Mocked<ElasticsearchServiceContract> = {
setup: jest.fn(),
start: jest.fn(),
stop: jest.fn(),
};
mocked.setup.mockResolvedValue(createSetupContractMock());
Expand Down
2 changes: 2 additions & 0 deletions src/core/server/elasticsearch/elasticsearch_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ export class ElasticsearchService implements CoreService<ElasticsearchServiceSet
};
}

public async start() {}

public async stop() {
this.log.debug('Stopping elasticsearch service');

Expand Down
48 changes: 4 additions & 44 deletions src/core/server/http/__snapshots__/http_service.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/core/server/http/http_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const createHttpSchema = schema.object(
}
);

type HttpConfigType = TypeOf<typeof createHttpSchema>;
export type HttpConfigType = TypeOf<typeof createHttpSchema>;

export class HttpConfig {
/**
Expand Down
Loading

0 comments on commit cdb8738

Please sign in to comment.