Skip to content

Commit

Permalink
Replace FetchOptions with ISearchOptions and update usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Liza K committed Sep 2, 2020
1 parent 3e07797 commit b7fd716
Show file tree
Hide file tree
Showing 29 changed files with 67 additions and 124 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

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

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [ISearchOptions](./kibana-plugin-plugins-data-public.isearchoptions.md) &gt; [signal](./kibana-plugin-plugins-data-public.isearchoptions.signal.md)
[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [ISearchOptions](./kibana-plugin-plugins-data-public.isearchoptions.md) &gt; [abortSignal](./kibana-plugin-plugins-data-public.isearchoptions.abortsignal.md)

## ISearchOptions.signal property
## ISearchOptions.abortSignal property

<b>Signature:</b>

```typescript
signal?: AbortSignal;
abortSignal?: AbortSignal;
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export interface ISearchOptions

| Property | Type | Description |
| --- | --- | --- |
| [signal](./kibana-plugin-plugins-data-public.isearchoptions.signal.md) | <code>AbortSignal</code> | |
| [abortSignal](./kibana-plugin-plugins-data-public.isearchoptions.abortsignal.md) | <code>AbortSignal</code> | |
| [strategy](./kibana-plugin-plugins-data-public.isearchoptions.strategy.md) | <code>string</code> | |

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
| [DataPublicPluginSetup](./kibana-plugin-plugins-data-public.datapublicpluginsetup.md) | |
| [DataPublicPluginStart](./kibana-plugin-plugins-data-public.datapublicpluginstart.md) | |
| [EsQueryConfig](./kibana-plugin-plugins-data-public.esqueryconfig.md) | |
| [FetchOptions](./kibana-plugin-plugins-data-public.fetchoptions.md) | |
| [FieldFormatConfig](./kibana-plugin-plugins-data-public.fieldformatconfig.md) | |
| [FieldMappingSpec](./kibana-plugin-plugins-data-public.fieldmappingspec.md) | |
| [Filter](./kibana-plugin-plugins-data-public.filter.md) | |
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/data/common/search/aggs/agg_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { Assign, Ensure } from '@kbn/utility-types';

import { FetchOptions, ISearchSource } from 'src/plugins/data/public';
import { ISearchOptions, ISearchSource } from 'src/plugins/data/public';
import {
ExpressionAstFunction,
ExpressionAstArgument,
Expand Down Expand Up @@ -213,11 +213,11 @@ export class AggConfig {

/**
* Hook for pre-flight logic, see AggType#onSearchRequestStart
* @param {Courier.SearchSource} searchSource
* @param {Courier.FetchOptions} options
* @param {SearchSource} searchSource
* @param {ISearchOptions} options
* @return {Promise<undefined>}
*/
onSearchRequestStart(searchSource: ISearchSource, options?: FetchOptions) {
onSearchRequestStart(searchSource: ISearchSource, options?: ISearchOptions) {
if (!this.type) {
return Promise.resolve();
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data/common/search/aggs/agg_configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import _ from 'lodash';
import { Assign } from '@kbn/utility-types';

import { FetchOptions, ISearchSource } from 'src/plugins/data/public';
import { ISearchOptions, ISearchSource } from 'src/plugins/data/public';
import { AggConfig, AggConfigSerialized, IAggConfig } from './agg_config';
import { IAggType } from './agg_type';
import { AggTypesRegistryStart } from './agg_types_registry';
Expand Down Expand Up @@ -300,7 +300,7 @@ export class AggConfigs {
return _.find(reqAgg.getResponseAggs(), { id });
}

onSearchRequestStart(searchSource: ISearchSource, options?: FetchOptions) {
onSearchRequestStart(searchSource: ISearchSource, options?: ISearchOptions) {
return Promise.all(
// @ts-ignore
this.getRequestAggs().map((agg: AggConfig) => agg.onSearchRequestStart(searchSource, options))
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data/common/search/aggs/param_types/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { FetchOptions, ISearchSource } from 'src/plugins/data/public';
import { ISearchOptions, ISearchSource } from 'src/plugins/data/public';
import { ExpressionAstFunction } from 'src/plugins/expressions/common';
import { IAggConfigs } from '../agg_configs';
import { IAggConfig } from '../agg_config';
Expand Down Expand Up @@ -56,7 +56,7 @@ export class BaseParamType<TAggConfig extends IAggConfig = IAggConfig> {
modifyAggConfigOnSearchRequestStart: (
aggConfig: TAggConfig,
searchSource?: ISearchSource,
options?: FetchOptions
options?: ISearchOptions
) => void;

constructor(config: Record<string, any>) {
Expand Down
1 change: 0 additions & 1 deletion src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ export {
ES_SEARCH_STRATEGY,
EsQuerySortValue,
extractSearchSourceReferences,
FetchOptions,
getEsPreference,
getSearchParamsFromRequest,
IEsSearchRequest,
Expand Down
44 changes: 17 additions & 27 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import { EuiGlobalToastListToast } from '@elastic/eui';
import { ExclusiveUnion } from '@elastic/eui';
import { ExpressionAstFunction } from 'src/plugins/expressions/common';
import { ExpressionsSetup } from 'src/plugins/expressions/public';
import { FetchOptions as FetchOptions_2 } from 'src/plugins/data/public';
import { History } from 'history';
import { Href } from 'history';
import { IconType } from '@elastic/eui';
import { InjectedIntl } from '@kbn/i18n/react';
import { ISearchOptions as ISearchOptions_2 } from 'src/plugins/data/public';
import { ISearchSource as ISearchSource_2 } from 'src/plugins/data/public';
import { IStorageWrapper } from 'src/plugins/kibana_utils/public';
import { IUiSettingsClient } from 'src/core/public';
Expand Down Expand Up @@ -486,16 +486,6 @@ export const extractSearchSourceReferences: (state: SearchSourceFields) => [Sear
indexRefName?: string;
}, SavedObjectReference[]];

// Warning: (ae-missing-release-tag) "FetchOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface FetchOptions {
// (undocumented)
abortSignal?: AbortSignal;
// (undocumented)
searchStrategyId?: string;
}

// Warning: (ae-missing-release-tag) "FieldFormat" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
Expand Down Expand Up @@ -1266,7 +1256,7 @@ export type ISearchGeneric = <SearchStrategyRequest extends IEsSearchRequest = I
// @public (undocumented)
export interface ISearchOptions {
// (undocumented)
signal?: AbortSignal;
abortSignal?: AbortSignal;
// (undocumented)
strategy?: string;
}
Expand Down Expand Up @@ -2003,21 +1993,21 @@ export const UI_SETTINGS: {
// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "getFromSavedObject" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:371:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:371:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:371:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:371:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:373:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:374:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:383:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:384:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:385:1 - (ae-forgotten-export) The symbol "Ipv4Address" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:386:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:390:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:391:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:394:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:395:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:398:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:370:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:370:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:370:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:370:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:372:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:373:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:382:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:383:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:384:1 - (ae-forgotten-export) The symbol "Ipv4Address" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:385:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:389:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:390:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:393:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:394:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:397:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/query/state_sync/connect_to_query_state.ts:45:5 - (ae-forgotten-export) The symbol "FilterStateStore" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/types.ts:62:5 - (ae-forgotten-export) The symbol "createFiltersFromValueClickAction" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/types.ts:63:5 - (ae-forgotten-export) The symbol "createFiltersFromRangeSelectAction" needs to be exported by the entry point index.d.ts
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/search/expressions/esdsl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const esdsl = (): EsdslExpressionFunctionDefinition => ({
body: dsl,
},
},
{ signal: abortSignal }
{ abortSignal }
)
.toPromise();

Expand Down
5 changes: 0 additions & 5 deletions src/plugins/data/public/search/fetch/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ import { ISearchStartLegacy } from '../types';
*/
export type SearchRequest = Record<string, any>;

export interface FetchOptions {
abortSignal?: AbortSignal;
searchStrategyId?: string;
}

export interface FetchHandlers {
legacySearchService: ISearchStartLegacy;
config: { get: GetConfigFn };
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export { getEsPreference } from './es_search';

export { IKibanaSearchResponse, IKibanaSearchRequest } from '../../common/search';

export { SearchError, FetchOptions, getSearchParamsFromRequest, SearchRequest } from './fetch';
export { SearchError, getSearchParamsFromRequest, SearchRequest } from './fetch';

export {
ISearchSource,
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/data/public/search/legacy/call_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@
*/

import { SearchResponse } from 'elasticsearch';
import { FetchOptions, FetchHandlers, handleResponse } from '../fetch';
import { FetchHandlers, handleResponse } from '../fetch';
import { defaultSearchStrategy } from './default_search_strategy';
import { SearchRequest } from '../index';
import { SearchRequest, ISearchOptions } from '../index';

export function callClient(
searchRequests: SearchRequest[],
requestsOptions: FetchOptions[] = [],
requestsOptions: ISearchOptions[] = [],
fetchHandlers: FetchHandlers
) {
// Correlate the options with the request that they're associated with
const requestOptionEntries: Array<[
SearchRequest,
FetchOptions
ISearchOptions
]> = searchRequests.map((request, i) => [request, requestsOptions[i]]);
const requestOptionsMap = new Map<SearchRequest, FetchOptions>(requestOptionEntries);
const requestOptionsMap = new Map<SearchRequest, ISearchOptions>(requestOptionEntries);
const requestResponseMap = new Map<SearchRequest, Promise<SearchResponse<any>>>();

const { searching, abort } = defaultSearchStrategy.search({
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/search/legacy/fetch_soon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { fetchSoon } from './fetch_soon';
import { callClient } from './call_client';
import { FetchHandlers, FetchOptions } from '../fetch/types';
import { FetchHandlers } from '../fetch/types';
import { SearchRequest } from '../index';
import { SearchResponse } from 'elasticsearch';
import { GetConfigFn, UI_SETTINGS } from '../../../common';
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/data/public/search/legacy/fetch_soon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import { SearchResponse } from 'elasticsearch';
import { callClient } from './call_client';
import { FetchHandlers, FetchOptions } from '../fetch/types';
import { SearchRequest } from '../index';
import { FetchHandlers } from '../fetch/types';
import { SearchRequest, ISearchOptions } from '../index';
import { UI_SETTINGS } from '../../../common';

/**
Expand All @@ -29,7 +29,7 @@ import { UI_SETTINGS } from '../../../common';
*/
export async function fetchSoon(
request: SearchRequest,
options: FetchOptions,
options: ISearchOptions,
fetchHandlers: FetchHandlers
) {
const msToDelay = fetchHandlers.config.get(UI_SETTINGS.COURIER_BATCH_SEARCHES) ? 50 : 0;
Expand All @@ -51,7 +51,7 @@ function delay<T>(fn: (...args: any) => T, ms: number): Promise<T> {

// The current batch/queue of requests to fetch
let requestsToFetch: SearchRequest[] = [];
let requestOptions: FetchOptions[] = [];
let requestOptions: ISearchOptions[] = [];

// The in-progress fetch (if there is one)
let fetchInProgress: any = null;
Expand All @@ -65,7 +65,7 @@ let fetchInProgress: any = null;
*/
async function delayedFetch(
request: SearchRequest,
options: FetchOptions,
options: ISearchOptions,
fetchHandlers: FetchHandlers,
ms: number
): Promise<SearchResponse<any>> {
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/data/public/search/search_interceptor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ describe('SearchInterceptor', () => {
const mockRequest: IEsSearchRequest = {
params: {},
};
const response = searchInterceptor.search(mockRequest, { signal: abortController.signal });
const response = searchInterceptor.search(mockRequest, {
abortSignal: abortController.signal,
});

const next = jest.fn();
const error = (e: any) => {
Expand All @@ -131,7 +133,7 @@ describe('SearchInterceptor', () => {
const mockRequest: IEsSearchRequest = {
params: {},
};
const response = searchInterceptor.search(mockRequest, { signal: abort.signal });
const response = searchInterceptor.search(mockRequest, { abortSignal: abort.signal });
abort.abort();

const error = (e: any) => {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data/public/search/search_interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class SearchInterceptor {
): Observable<IEsSearchResponse> {
// Defer the following logic until `subscribe` is actually called
return defer(() => {
if (options?.signal?.aborted) {
if (options?.abortSignal?.aborted) {
return throwError(new AbortError());
}

Expand Down Expand Up @@ -164,7 +164,7 @@ export class SearchInterceptor {
const signals = [
this.abortController.signal,
timeoutSignal,
...(options?.signal ? [options.signal] : []),
...(options?.abortSignal ? [options.abortSignal] : []),
];

const combinedSignal = getCombinedSignal(signals);
Expand Down
Loading

0 comments on commit b7fd716

Please sign in to comment.