Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
173b1b9
Move inspector adapter integration into search source
Apr 5, 2021
d3c9dbb
docs and ts
Apr 6, 2021
f927075
Merge branch 'master' of github.com:elastic/kibana into search/inspec…
Apr 6, 2021
f44c320
Merge branch 'master' of github.com:elastic/kibana into search/inspec…
Apr 6, 2021
413b462
Move other bucket to search source
Apr 7, 2021
7862457
test ts + delete unused tabilfy function
Apr 7, 2021
1bd2887
Merge branch 'master' of github.com:elastic/kibana into search/move-o…
Apr 7, 2021
f22bab9
Merge branch 'master' of github.com:elastic/kibana into search/move-o…
Apr 11, 2021
b9301dd
hierarchical param in aggconfig.
Apr 11, 2021
e88df9d
fix jest
Apr 11, 2021
47b9944
separate inspect
Apr 11, 2021
b9ce734
jest
Apr 12, 2021
2976277
inspector
Apr 12, 2021
8d4aafe
Error handling and more tests
Apr 12, 2021
f2d202e
Merge branch 'master' of github.com:elastic/kibana into search/move-o…
Apr 12, 2021
f5e9a1b
Merge branch 'master' of github.com:elastic/kibana into search/move-o…
Apr 13, 2021
c7514ee
put the fun in functional tests
Apr 13, 2021
500c226
delete client side legacy msearch code
Apr 13, 2021
504d1da
ts
Apr 13, 2021
75e3532
Merge branch 'master' of github.com:elastic/kibana into search/remove…
Apr 19, 2021
f4b7aa3
Merge branch 'master' of github.com:elastic/kibana into search/remove…
Apr 19, 2021
37336f3
Merge branch 'master' of github.com:elastic/kibana into search/remove…
Apr 21, 2021
ce1a83a
override to sync search in search source
Apr 21, 2021
c7a7827
delete more legacy code
Apr 21, 2021
ed547f1
ts
Apr 21, 2021
c10110f
delete moarrrr
Apr 21, 2021
792e517
Merge branch 'master' of github.com:elastic/kibana into search/remove…
Apr 22, 2021
e6212a4
Merge branch 'master' of github.com:elastic/kibana into search/remove…
Apr 22, 2021
af896c7
deflate bfetch chunks
Apr 22, 2021
dcf5d2e
update tests
Apr 22, 2021
2d6192f
ts
Apr 22, 2021
44416cb
extract getInflatedResponse
Apr 22, 2021
2ad860e
tests
Apr 22, 2021
8397d3d
Use fflate in attempt to reduce package size
Apr 22, 2021
4523195
Merge branch 'master' of github.com:elastic/kibana into bfetch/compre…
Apr 28, 2021
68459e3
Merge branch 'master' of github.com:elastic/kibana into bfetch/compre…
Apr 29, 2021
2507bfb
Merge branch 'master' of github.com:elastic/kibana into bfetch/compre…
Apr 29, 2021
a88372b
use node streams, fflate and hex encoding.
May 2, 2021
d5e2e0d
Merge branch 'master' of github.com:elastic/kibana into bfetch/compre…
May 5, 2021
83e6f61
DISABLE_SEARCH_COMPRESSION UI Settings
May 5, 2021
096901a
Merge branch 'master' of github.com:elastic/kibana into bfetch/compre…
May 5, 2021
23d8252
i18n
May 5, 2021
ad6e056
Code review
May 5, 2021
c1c9382
use custom headers
May 5, 2021
b450f23
Update jest
May 5, 2021
b27d151
fix tests
May 6, 2021
4881ca6
Merge branch 'master' of github.com:elastic/kibana into bfetch/compre…
May 6, 2021
ce259c4
Merge branch 'master' of github.com:elastic/kibana into bfetch/compre…
May 6, 2021
611df93
code review, baby!
May 6, 2021
a06d709
integration
May 6, 2021
dd897a7
Merge branch 'master' of github.com:elastic/kibana into bfetch/compre…
May 9, 2021
9d21b3a
tests
May 9, 2021
a139f9e
limit
May 9, 2021
b442879
limit
May 9, 2021
09026d7
Merge branch 'master' into bfetch/compress-stream
kibanamachine May 11, 2021
66a0207
Merge branch 'master' into bfetch/compress-stream
kibanamachine May 13, 2021
ae47a8f
Merge branch 'master' into bfetch/compress-stream
kibanamachine May 16, 2021
b4dde7d
Merge branch 'master' into bfetch/compress-stream
kibanamachine May 18, 2021
43647ed
Merge branch 'master' into bfetch/compress-stream
kibanamachine May 19, 2021
f5ef42f
Merge branch 'master' into bfetch/compress-stream
kibanamachine May 24, 2021
3626414
Merge branch 'master' into bfetch/compress-stream
kibanamachine May 25, 2021
5540010
Merge branch 'master' of github.com:elastic/kibana into bfetch/compre…
May 30, 2021
f2f6f77
Merge branch 'bfetch/compress-stream' of github.com:lizozom/kibana in…
May 30, 2021
d07b8eb
limit
May 31, 2021
df3fecb
Merge branch 'master' of github.com:elastic/kibana into bfetch/compre…
May 31, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"console": "src/plugins/console",
"core": "src/core",
"discover": "src/plugins/discover",
"bfetch": "src/plugins/bfetch",
"dashboard": "src/plugins/dashboard",
"data": "src/plugins/data",
"embeddableApi": "src/plugins/embeddable",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@
"expiry-js": "0.1.7",
"extract-zip": "^2.0.1",
"fast-deep-equal": "^3.1.1",
"fflate": "^0.6.9",
"file-saver": "^1.3.8",
"file-type": "^10.9.0",
"focus-trap-react": "^3.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pageLoadAssetSize:
alerting: 106936
apm: 64385
apmOss: 18996
bfetch: 41874
bfetch: 51874
canvas: 1066647
charts: 195358
cloud: 21076
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-ui-shared-deps/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export const Theme = require('./theme.ts');
export const Lodash = require('lodash');
export const LodashFp = require('lodash/fp');

export const Fflate = require('fflate/esm/browser');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should it be in kbn-ui-shared-deps?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spalger suggestion - kbn-ui-shared-deps is minified more strongly, so it seems. 🤷🏻

Copy link
Copy Markdown
Contributor

@spalger spalger May 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two reasons, first because of the minification available in ui-shared-deps and second because it allows us to rewrite the imports from common dirs to fflate/esm/browser but let them import the default implementation in node.

All that said, I didn't learn about the DecompressionStream API until yesterday so I'm wondering if fflate is the best option or if we should be using this API which appears supported in all necessary browsers.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, seeing the other discussion in here it sounds like DecompressionStreams have already been ruled out


// runtime deps which don't need to be copied across all bundles
export const TsLib = require('tslib');
export const KbnAnalytics = require('@kbn/analytics');
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-ui-shared-deps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ exports.externals = {
'@elastic/eui/dist/eui_theme_dark.json': '__kbnSharedDeps__.Theme.euiDarkVars',
lodash: '__kbnSharedDeps__.Lodash',
'lodash/fp': '__kbnSharedDeps__.LodashFp',
fflate: '__kbnSharedDeps__.Fflate',

/**
* runtime deps which don't need to be copied across all bundles
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/bfetch/common/batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ export interface BatchResponseItem<Result extends object, Error extends ErrorLik
result?: Result;
error?: Error;
}

export interface BatchItemWrapper {
compressed: boolean;
payload: string;
}
9 changes: 9 additions & 0 deletions src/plugins/bfetch/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* 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.
*/

export const DISABLE_BFETCH_COMPRESSION = 'bfetch:disableCompression';
1 change: 1 addition & 0 deletions src/plugins/bfetch/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export * from './util';
export * from './streaming';
export * from './buffer';
export * from './batch';
export * from './constants';
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import { createStreamingBatchedFunction } from './create_streaming_batched_function';
import { fetchStreaming as fetchStreamingReal } from '../streaming/fetch_streaming';
import { AbortError, defer, of } from '../../../kibana_utils/public';
import { Subject } from 'rxjs';
import { Subject, of as rxof } from 'rxjs';

const flushPromises = () => new Promise((resolve) => setImmediate(resolve));

const getPromiseState = (promise: Promise<unknown>): Promise<'resolved' | 'rejected' | 'pending'> =>
Promise.race<'resolved' | 'rejected' | 'pending'>([
Expand Down Expand Up @@ -52,6 +54,7 @@ describe('createStreamingBatchedFunction()', () => {
const fn = createStreamingBatchedFunction({
url: '/test',
fetchStreaming,
compressionDisabled$: rxof(true),
});
expect(typeof fn).toBe('function');
});
Expand All @@ -61,6 +64,7 @@ describe('createStreamingBatchedFunction()', () => {
const fn = createStreamingBatchedFunction({
url: '/test',
fetchStreaming,
compressionDisabled$: rxof(true),
});
const res = fn({});
expect(typeof res.then).toBe('function');
Expand All @@ -74,6 +78,7 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

expect(fetchStreaming).toHaveBeenCalledTimes(0);
Expand All @@ -93,6 +98,7 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

expect(fetchStreaming).toHaveBeenCalledTimes(0);
Expand All @@ -107,6 +113,7 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

fn({ foo: 'bar' });
Expand All @@ -125,6 +132,7 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

fn({ foo: 'bar' });
Expand All @@ -146,14 +154,18 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

expect(fetchStreaming).toHaveBeenCalledTimes(0);
fn({ foo: 'bar' });
await flushPromises();
expect(fetchStreaming).toHaveBeenCalledTimes(0);
fn({ baz: 'quix' });
await flushPromises();
expect(fetchStreaming).toHaveBeenCalledTimes(0);
fn({ full: 'yep' });
await flushPromises();
expect(fetchStreaming).toHaveBeenCalledTimes(1);
});

Expand All @@ -164,6 +176,7 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

const abortController = new AbortController();
Expand All @@ -186,11 +199,13 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

fn({ a: '1' });
fn({ b: '2' });
fn({ c: '3' });
await flushPromises();

expect(fetchStreaming.mock.calls[0][0]).toMatchObject({
url: '/test',
Expand All @@ -209,13 +224,16 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

fn({ a: '1' });
fn({ b: '2' });
fn({ c: '3' });
await flushPromises();
expect(fetchStreaming).toHaveBeenCalledTimes(1);
fn({ d: '4' });
await flushPromises();
await new Promise((r) => setTimeout(r, 6));
expect(fetchStreaming).toHaveBeenCalledTimes(2);
});
Expand All @@ -229,6 +247,7 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

const promise1 = fn({ a: '1' });
Expand All @@ -246,8 +265,11 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

await flushPromises();

const promise1 = fn({ a: '1' });
const promise2 = fn({ b: '2' });
const promise3 = fn({ c: '3' });
Expand Down Expand Up @@ -287,6 +309,7 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

const promise1 = fn({ a: '1' });
Expand Down Expand Up @@ -314,13 +337,28 @@ describe('createStreamingBatchedFunction()', () => {
expect(await promise3).toEqual({ foo: 'bar 2' });
});

test('compression is false by default', async () => {
const { fetchStreaming } = setup();
const fn = createStreamingBatchedFunction({
url: '/test',
flushOnMaxItems: 1,
fetchStreaming,
});

fn({ a: '1' });

const dontCompress = await fetchStreaming.mock.calls[0][0].compressionDisabled$.toPromise();
expect(dontCompress).toBe(false);
});

test('resolves falsy results', async () => {
const { fetchStreaming, stream } = setup();
const fn = createStreamingBatchedFunction({
url: '/test',
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

const promise1 = fn({ a: '1' });
Expand Down Expand Up @@ -362,6 +400,7 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

const promise = fn({ a: '1' });
Expand Down Expand Up @@ -390,6 +429,7 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

const promise1 = of(fn({ a: '1' }));
Expand Down Expand Up @@ -442,6 +482,7 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

const abortController = new AbortController();
Expand Down Expand Up @@ -471,6 +512,7 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

const abortController = new AbortController();
Expand Down Expand Up @@ -509,6 +551,7 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

const promise1 = of(fn({ a: '1' }));
Expand Down Expand Up @@ -539,6 +582,7 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

const promise1 = of(fn({ a: '1' }));
Expand Down Expand Up @@ -576,6 +620,7 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

const promise1 = of(fn({ a: '1' }));
Expand Down Expand Up @@ -608,6 +653,7 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});

const promise1 = of(fn({ a: '1' }));
Expand Down Expand Up @@ -644,7 +690,9 @@ describe('createStreamingBatchedFunction()', () => {
fetchStreaming,
maxItemAge: 5,
flushOnMaxItems: 3,
compressionDisabled$: rxof(true),
});
await flushPromises();

const promise1 = of(fn({ a: '1' }));
const promise2 = of(fn({ a: '2' }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
* Side Public License, v 1.
*/

import { Observable, of } from 'rxjs';
import { AbortError, abortSignalToPromise, defer } from '../../../kibana_utils/public';
import {
ItemBufferParams,
TimedItemBufferParams,
createBatchedFunction,
BatchResponseItem,
ErrorLike,
normalizeError,
} from '../../common';
import { fetchStreaming, split } from '../streaming';
import { normalizeError } from '../../common';
import { fetchStreaming } from '../streaming';
import { BatchedFunc, BatchItem } from './types';

export interface BatchedFunctionProtocolError extends ErrorLike {
Expand Down Expand Up @@ -47,6 +47,11 @@ export interface StreamingBatchedFunctionParams<Payload, Result> {
* before sending the batch request.
*/
maxItemAge?: TimedItemBufferParams<any>['maxItemAge'];

/**
* Disabled zlib compression of response chunks.
*/
compressionDisabled$?: Observable<boolean>;
}

/**
Expand All @@ -64,6 +69,7 @@ export const createStreamingBatchedFunction = <Payload, Result extends object>(
fetchStreaming: fetchStreamingInjected = fetchStreaming,
flushOnMaxItems = 25,
maxItemAge = 10,
compressionDisabled$ = of(false),
} = params;
const [fn] = createBatchedFunction({
onCall: (payload: Payload, signal?: AbortSignal) => {
Expand Down Expand Up @@ -119,6 +125,7 @@ export const createStreamingBatchedFunction = <Payload, Result extends object>(
body: JSON.stringify({ batch }),
method: 'POST',
signal: abortController.signal,
compressionDisabled$,
});

const handleStreamError = (error: any) => {
Expand All @@ -127,10 +134,10 @@ export const createStreamingBatchedFunction = <Payload, Result extends object>(
for (const { future } of items) future.reject(normalizedError);
};

stream.pipe(split('\n')).subscribe({
stream.subscribe({
next: (json: string) => {
try {
const response = JSON.parse(json) as BatchResponseItem<Result, ErrorLike>;
const response = JSON.parse(json);
if (response.error) {
items[response.id].future.reject(response.error);
} else if (response.result !== undefined) {
Expand Down
12 changes: 12 additions & 0 deletions src/plugins/bfetch/public/batching/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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.
*/

export {
createStreamingBatchedFunction,
StreamingBatchedFunctionParams,
} from './create_streaming_batched_function';
Loading