forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose core api types in /public and /server (#32746) (#33477)
* Expose core api types in /public and /server * Export CoreStart from core/public * Export Server and Public from 'kibana' * Cast frozen object type back to original The exported type `InjectedMetadataStart` derives it's type from the returned values. Since it's internal state is frozen the type changes to `ReadOnly<`. However, consumers of the API shouldn't have to know or care about this type. * Be more selective with what gets exported * Fix type imports in tests * Fix type errors * Remove src/type_exports.ts * More remove src/type_exports.ts * Remove build:types * Fix bootstrap import * Expose internal API's at the top level Exposing the internal API's at the top level of core/public and core/server makes it obvious that these API's are consumed outside these modules. Marking these @internal ensures they don't get exported as part of the documentation. * Fix tests * Put core/{public/server} in their own namespaces
- Loading branch information
Showing
20 changed files
with
152 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import * as Public from './public'; | ||
import * as Server from './server'; | ||
|
||
export { Public, Server }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { first } from 'rxjs/operators'; | ||
import { ConfigService, Env } from './config'; | ||
import { ElasticsearchModule } from './elasticsearch'; | ||
import { HttpConfig, HttpModule, HttpServerInfo } from './http'; | ||
import { LegacyCompatModule } from './legacy'; | ||
import { Logger, LoggerFactory } from './logging'; | ||
import { PluginsModule } from './plugins'; | ||
|
||
export class Server { | ||
private readonly elasticsearch: ElasticsearchModule; | ||
private readonly http: HttpModule; | ||
private readonly plugins: PluginsModule; | ||
private readonly legacy: LegacyCompatModule; | ||
private readonly log: Logger; | ||
|
||
constructor(configService: ConfigService, logger: LoggerFactory, private readonly env: Env) { | ||
this.log = logger.get('server'); | ||
|
||
this.http = new HttpModule(configService.atPath('server', HttpConfig), logger); | ||
|
||
const core = { env, configService, logger }; | ||
this.plugins = new PluginsModule(core); | ||
this.legacy = new LegacyCompatModule(core); | ||
this.elasticsearch = new ElasticsearchModule(core); | ||
} | ||
|
||
public async start() { | ||
this.log.debug('starting server'); | ||
|
||
// We shouldn't start http service in two cases: | ||
// 1. If `server.autoListen` is explicitly set to `false`. | ||
// 2. When the process is run as dev cluster master in which case cluster manager | ||
// will fork a dedicated process where http service will be started instead. | ||
let httpStart: HttpServerInfo | undefined; | ||
const httpConfig = await this.http.config$.pipe(first()).toPromise(); | ||
if (!this.env.isDevClusterMaster && httpConfig.autoListen) { | ||
httpStart = await this.http.service.start(); | ||
} | ||
|
||
const elasticsearchServiceStart = await this.elasticsearch.service.start(); | ||
|
||
const pluginsStart = await this.plugins.service.start({ | ||
elasticsearch: elasticsearchServiceStart, | ||
}); | ||
|
||
await this.legacy.service.start({ | ||
elasticsearch: elasticsearchServiceStart, | ||
http: httpStart, | ||
plugins: pluginsStart, | ||
}); | ||
} | ||
|
||
public async stop() { | ||
this.log.debug('stopping server'); | ||
|
||
await this.legacy.service.stop(); | ||
await this.plugins.service.stop(); | ||
await this.elasticsearch.service.stop(); | ||
await this.http.service.stop(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.