-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into kbn-xxx-split-integ…
…ration-tests
- Loading branch information
Showing
276 changed files
with
1,870 additions
and
705 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
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
101 changes: 101 additions & 0 deletions
101
packages/core/base/core-base-common/src/service_status.ts
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,101 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { deepFreeze } from '@kbn/std'; | ||
|
||
/** | ||
* The current status of a service at a point in time. | ||
* | ||
* @typeParam Meta - JSON-serializable object. Plugins should export this type to allow other plugins to read the `meta` | ||
* field in a type-safe way. | ||
* @public | ||
*/ | ||
export interface ServiceStatus<Meta extends Record<string, any> | unknown = unknown> { | ||
/** | ||
* The current availability level of the service. | ||
*/ | ||
level: ServiceStatusLevel; | ||
/** | ||
* A high-level summary of the service status. | ||
*/ | ||
summary: string; | ||
/** | ||
* A more detailed description of the service status. | ||
*/ | ||
detail?: string; | ||
/** | ||
* A URL to open in a new tab about how to resolve or troubleshoot the problem. | ||
*/ | ||
documentationUrl?: string; | ||
/** | ||
* Any JSON-serializable data to be included in the HTTP API response. Useful for providing more fine-grained, | ||
* machine-readable information about the service status. May include status information for underlying features. | ||
*/ | ||
meta?: Meta; | ||
} | ||
|
||
/** | ||
* The current "level" of availability of a service. | ||
* | ||
* @remarks | ||
* The values implement `valueOf` to allow for easy comparisons between status levels with <, >, etc. Higher values | ||
* represent higher severities. Note that the default `Array.prototype.sort` implementation does not correctly sort | ||
* these values. | ||
* | ||
* A snapshot serializer is available in `src/core/server/test_utils` to ease testing of these values with Jest. | ||
* | ||
* @public | ||
*/ | ||
export const ServiceStatusLevels = deepFreeze({ | ||
/** | ||
* Everything is working! | ||
*/ | ||
available: { | ||
toString: () => 'available', | ||
valueOf: () => 0, | ||
toJSON() { | ||
return this.toString(); | ||
}, | ||
}, | ||
/** | ||
* Some features may not be working. | ||
*/ | ||
degraded: { | ||
toString: () => 'degraded', | ||
valueOf: () => 1, | ||
toJSON() { | ||
return this.toString(); | ||
}, | ||
}, | ||
/** | ||
* The service is unavailable, but other functions that do not depend on this service should work. | ||
*/ | ||
unavailable: { | ||
toString: () => 'unavailable', | ||
valueOf: () => 2, | ||
toJSON() { | ||
return this.toString(); | ||
}, | ||
}, | ||
/** | ||
* Block all user functions and display the status page, reserved for Core services only. | ||
*/ | ||
critical: { | ||
toString: () => 'critical', | ||
valueOf: () => 3, | ||
toJSON() { | ||
return this.toString(); | ||
}, | ||
}, | ||
}); | ||
|
||
/** | ||
* A convenience type that represents the union of each value in {@link ServiceStatusLevels}. | ||
* @public | ||
*/ | ||
export type ServiceStatusLevel = typeof ServiceStatusLevels[keyof typeof ServiceStatusLevels]; |
116 changes: 116 additions & 0 deletions
116
packages/core/elasticsearch/core-elasticsearch-client-server-internal/BUILD.bazel
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,116 @@ | ||
load("@npm//@bazel/typescript:index.bzl", "ts_config") | ||
load("@build_bazel_rules_nodejs//:index.bzl", "js_library") | ||
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project") | ||
|
||
PKG_DIRNAME = "core-elasticsearch-client-server-internal" | ||
PKG_REQUIRE_NAME = "@kbn/core-elasticsearch-client-server-internal" | ||
|
||
SOURCE_FILES = glob( | ||
[ | ||
"src/**/*.ts", | ||
], | ||
exclude = [ | ||
"**/*.test.*", | ||
"**/*.stories.*", | ||
], | ||
) | ||
|
||
SRCS = SOURCE_FILES | ||
|
||
filegroup( | ||
name = "srcs", | ||
srcs = SRCS, | ||
) | ||
|
||
NPM_MODULE_EXTRA_FILES = [ | ||
"package.json", | ||
] | ||
|
||
RUNTIME_DEPS = [ | ||
"@npm//moment", | ||
"@npm//@elastic/elasticsearch", | ||
"@npm//@elastic/numeral", | ||
"//packages/kbn-std", | ||
"//packages/kbn-es-errors", | ||
"//packages/core/http/core-http-router-server-internal", | ||
### test dependencies | ||
"//packages/core/logging/core-logging-server-mocks", | ||
"//packages/core/http/core-http-server-mocks", | ||
] | ||
|
||
TYPES_DEPS = [ | ||
"@npm//@types/node", | ||
"@npm//@types/jest", | ||
"@npm//moment", | ||
"@npm//@elastic/elasticsearch", | ||
"@npm//@elastic/numeral", | ||
"//packages/kbn-utility-types:npm_module_types", | ||
"//packages/kbn-std:npm_module_types", | ||
"//packages/kbn-es-errors:npm_module_types", | ||
"//packages/kbn-logging:npm_module_types", | ||
"//packages/core/http/core-http-server:npm_module_types", | ||
"//packages/core/http/core-http-router-server-internal:npm_module_types", | ||
"//packages/core/elasticsearch/core-elasticsearch-server:npm_module_types", | ||
] | ||
|
||
jsts_transpiler( | ||
name = "target_node", | ||
srcs = SRCS, | ||
build_pkg_name = package_name(), | ||
) | ||
|
||
ts_config( | ||
name = "tsconfig", | ||
src = "tsconfig.json", | ||
deps = [ | ||
"//:tsconfig.base.json", | ||
"//:tsconfig.bazel.json", | ||
], | ||
) | ||
|
||
ts_project( | ||
name = "tsc_types", | ||
args = ['--pretty'], | ||
srcs = SRCS, | ||
deps = TYPES_DEPS, | ||
declaration = True, | ||
declaration_map = True, | ||
emit_declaration_only = True, | ||
out_dir = "target_types", | ||
root_dir = "src", | ||
tsconfig = ":tsconfig", | ||
) | ||
|
||
js_library( | ||
name = PKG_DIRNAME, | ||
srcs = NPM_MODULE_EXTRA_FILES, | ||
deps = RUNTIME_DEPS + [":target_node"], | ||
package_name = PKG_REQUIRE_NAME, | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
pkg_npm( | ||
name = "npm_module", | ||
deps = [":" + PKG_DIRNAME], | ||
) | ||
|
||
filegroup( | ||
name = "build", | ||
srcs = [":npm_module"], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
pkg_npm_types( | ||
name = "npm_module_types", | ||
srcs = SRCS, | ||
deps = [":tsc_types"], | ||
package_name = PKG_REQUIRE_NAME, | ||
tsconfig = ":tsconfig", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
filegroup( | ||
name = "build_types", | ||
srcs = [":npm_module_types"], | ||
visibility = ["//visibility:public"], | ||
) |
3 changes: 3 additions & 0 deletions
3
packages/core/elasticsearch/core-elasticsearch-client-server-internal/README.md
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,3 @@ | ||
# @kbn/core-elasticsearch-client-server-internal | ||
|
||
This package contains the internal implementation for Core's server-side elasticsearch client. |
13 changes: 13 additions & 0 deletions
13
packages/core/elasticsearch/core-elasticsearch-client-server-internal/jest.config.js
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,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
module.exports = { | ||
preset: '@kbn/test/jest_node', | ||
rootDir: '../../../..', | ||
roots: ['<rootDir>/packages/core/elasticsearch/core-elasticsearch-client-server-internal'], | ||
}; |
7 changes: 7 additions & 0 deletions
7
packages/core/elasticsearch/core-elasticsearch-client-server-internal/package.json
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,7 @@ | ||
{ | ||
"name": "@kbn/core-elasticsearch-client-server-internal", | ||
"private": true, | ||
"version": "1.0.0", | ||
"main": "./target_node/index.js", | ||
"license": "SSPL-1.0 OR Elastic License 2.0" | ||
} |
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.
Oops, something went wrong.