mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
Move ItemBuffer to package (#196455)
## Summary Part of https://github.com/elastic/kibana/issues/186139. Bfetch exports `ItemBuffer` and `TimedItemBuffer`, the latter of which is also used inside of the content management plugin. After bfetch is removed, content management will be the sole consumer, which is why I've added the team ownership to be appex-sharedux. ### Checklist - [x] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
96585a540b
commit
b0bae065d4
24 changed files with 89 additions and 20 deletions
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
|
@ -541,6 +541,7 @@ x-pack/plugins/observability_solution/investigate @elastic/obs-ux-management-tea
|
|||
packages/kbn-investigation-shared @elastic/obs-ux-management-team
|
||||
packages/kbn-io-ts-utils @elastic/obs-knowledge-team
|
||||
packages/kbn-ipynb @elastic/search-kibana
|
||||
packages/kbn-item-buffer @elastic/appex-sharedux
|
||||
packages/kbn-jest-serializers @elastic/kibana-operations
|
||||
packages/kbn-journeys @elastic/kibana-operations @elastic/appex-qa
|
||||
packages/kbn-json-ast @elastic/kibana-operations
|
||||
|
|
|
@ -588,6 +588,7 @@
|
|||
"@kbn/investigation-shared": "link:packages/kbn-investigation-shared",
|
||||
"@kbn/io-ts-utils": "link:packages/kbn-io-ts-utils",
|
||||
"@kbn/ipynb": "link:packages/kbn-ipynb",
|
||||
"@kbn/item-buffer": "link:packages/kbn-item-buffer",
|
||||
"@kbn/json-schemas": "link:x-pack/packages/ml/json_schemas",
|
||||
"@kbn/kbn-health-gateway-status-plugin": "link:test/health_gateway/plugins/status",
|
||||
"@kbn/kbn-sample-panel-action-plugin": "link:test/plugin_functional/plugins/kbn_sample_panel_action",
|
||||
|
|
4
packages/kbn-item-buffer/README.md
Normal file
4
packages/kbn-item-buffer/README.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
# @kbn/item-buffer
|
||||
|
||||
`ItemBuffer`: A simple buffer that collects items. Can be cleared or flushed; and can automatically flush when specified number of items is reached.
|
||||
`TimedItemBuffer`: An `ItemBuffer` that flushes buffer when oldest item reaches age specified by this parameter, in milliseconds.
|
11
packages/kbn-item-buffer/index.ts
Normal file
11
packages/kbn-item-buffer/index.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
export { ItemBuffer, TimedItemBuffer } from './src';
|
||||
export type { ItemBufferParams, TimedItemBufferParams } from './src';
|
14
packages/kbn-item-buffer/jest.config.js
Normal file
14
packages/kbn-item-buffer/jest.config.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test/jest_node',
|
||||
rootDir: '../..',
|
||||
roots: ['<rootDir>/packages/kbn-item-buffer'],
|
||||
};
|
5
packages/kbn-item-buffer/kibana.jsonc
Normal file
5
packages/kbn-item-buffer/kibana.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type": "shared-common",
|
||||
"id": "@kbn/item-buffer",
|
||||
"owner": "@elastic/appex-sharedux"
|
||||
}
|
6
packages/kbn-item-buffer/package.json
Normal file
6
packages/kbn-item-buffer/package.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "@kbn/item-buffer",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0"
|
||||
}
|
11
packages/kbn-item-buffer/src/index.ts
Normal file
11
packages/kbn-item-buffer/src/index.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
export * from './item_buffer';
|
||||
export * from './timed_item_buffer';
|
|
@ -7,7 +7,7 @@
|
|||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
import { ItemBuffer } from '../item_buffer';
|
||||
import { runItemBufferTests } from './run_item_buffer_tests';
|
||||
import { ItemBuffer } from './item_buffer';
|
||||
import { runItemBufferTests } from './__test__/run_item_buffer_tests';
|
||||
|
||||
runItemBufferTests(ItemBuffer);
|
|
@ -7,8 +7,8 @@
|
|||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
import { TimedItemBuffer } from '../timed_item_buffer';
|
||||
import { runItemBufferTests } from './run_item_buffer_tests';
|
||||
import { TimedItemBuffer } from './timed_item_buffer';
|
||||
import { runItemBufferTests } from './__test__/run_item_buffer_tests';
|
||||
|
||||
jest.useFakeTimers({ legacyFakeTimers: true });
|
||||
|
17
packages/kbn-item-buffer/tsconfig.json
Normal file
17
packages/kbn-item-buffer/tsconfig.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "target/types",
|
||||
"types": [
|
||||
"jest",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*"
|
||||
],
|
||||
"kbn_references": []
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
import { createBatchedFunction } from '../create_batched_function';
|
||||
import { createBatchedFunction } from './create_batched_function';
|
||||
|
||||
describe('createBatchedFunction', () => {
|
||||
test('calls onCall every time fn is called, calls onBatch once flushOnMaxItems reached', async () => {
|
|
@ -7,8 +7,8 @@
|
|||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
import { ItemBufferParams } from './item_buffer';
|
||||
import { TimedItemBufferParams, TimedItemBuffer } from './timed_item_buffer';
|
||||
import type { ItemBufferParams, TimedItemBufferParams } from '@kbn/item-buffer';
|
||||
import { TimedItemBuffer } from '@kbn/item-buffer';
|
||||
|
||||
type Fn = (...args: any) => any;
|
||||
|
||||
|
|
|
@ -7,6 +7,4 @@
|
|||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
export * from './item_buffer';
|
||||
export * from './timed_item_buffer';
|
||||
export * from './create_batched_function';
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
|
||||
export { normalizeError, removeLeadingSlash, appendQueryParam } from './util';
|
||||
export type { StreamingResponseHandler } from './streaming';
|
||||
export type { ItemBufferParams, TimedItemBufferParams, BatchedFunctionParams } from './buffer';
|
||||
export { ItemBuffer, TimedItemBuffer, createBatchedFunction } from './buffer';
|
||||
export { type BatchedFunctionParams, createBatchedFunction } from './buffer';
|
||||
export type { ErrorLike, BatchRequestData, BatchResponseItem, BatchItemWrapper } from './batch';
|
||||
export {
|
||||
DISABLE_BFETCH_COMPRESSION,
|
||||
|
|
|
@ -8,13 +8,8 @@
|
|||
*/
|
||||
|
||||
import { AbortError, abortSignalToPromise, defer } from '@kbn/kibana-utils-plugin/public';
|
||||
import {
|
||||
ItemBufferParams,
|
||||
TimedItemBufferParams,
|
||||
createBatchedFunction,
|
||||
ErrorLike,
|
||||
normalizeError,
|
||||
} from '../../common';
|
||||
import type { ItemBufferParams, TimedItemBufferParams } from '@kbn/item-buffer';
|
||||
import { createBatchedFunction, ErrorLike, normalizeError } from '../../common';
|
||||
import { fetchStreaming } from '../streaming';
|
||||
import { BatchedFunc, BatchItem } from './types';
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"@kbn/core-http-common",
|
||||
"@kbn/bfetch-error",
|
||||
"@kbn/ebt-tools",
|
||||
"@kbn/item-buffer",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
import type { CoreSetup } from '@kbn/core/server';
|
||||
import { TimedItemBuffer } from '@kbn/bfetch-plugin/common';
|
||||
import { TimedItemBuffer } from '@kbn/item-buffer';
|
||||
import type {
|
||||
EventStreamClient,
|
||||
EventStreamClientFactory,
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"@kbn/core-http-request-handler-context-server",
|
||||
"@kbn/es-query",
|
||||
"@kbn/core-test-helpers-kbn-server",
|
||||
"@kbn/bfetch-plugin",
|
||||
"@kbn/item-buffer",
|
||||
"@kbn/object-versioning",
|
||||
"@kbn/core-saved-objects-api-server-mocks",
|
||||
"@kbn/core-saved-objects-api-server",
|
||||
|
|
|
@ -1076,6 +1076,8 @@
|
|||
"@kbn/io-ts-utils/*": ["packages/kbn-io-ts-utils/*"],
|
||||
"@kbn/ipynb": ["packages/kbn-ipynb"],
|
||||
"@kbn/ipynb/*": ["packages/kbn-ipynb/*"],
|
||||
"@kbn/item-buffer": ["packages/kbn-item-buffer"],
|
||||
"@kbn/item-buffer/*": ["packages/kbn-item-buffer/*"],
|
||||
"@kbn/jest-serializers": ["packages/kbn-jest-serializers"],
|
||||
"@kbn/jest-serializers/*": ["packages/kbn-jest-serializers/*"],
|
||||
"@kbn/journeys": ["packages/kbn-journeys"],
|
||||
|
|
|
@ -5447,6 +5447,10 @@
|
|||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/item-buffer@link:packages/kbn-item-buffer":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/jest-serializers@link:packages/kbn-jest-serializers":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue