Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data plugin: Suggested enhance pattern #74505

Merged
merged 22 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [SearchInterceptor](./kibana-plugin-plugins-data-public.searchinterceptor.md) > [getPendingCount$](./kibana-plugin-plugins-data-public.searchinterceptor.getpendingcount_.md)

## SearchInterceptor.getPendingCount$ property
## SearchInterceptor.getPendingCount$() method

Returns an `Observable` over the current number of pending searches. This could mean that one of the search requests is still in flight, or that it has only received partial responses.

<b>Signature:</b>

```typescript
getPendingCount$: () => Observable<number>;
getPendingCount$(): Observable<number>;
```
<b>Returns:</b>

`Observable<number>`

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,15 @@ export declare class SearchInterceptor

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [abortController](./kibana-plugin-plugins-data-public.searchinterceptor.abortcontroller.md) | | <code>AbortController</code> | <code>abortController</code> used to signal all searches to abort. |
| [deps](./kibana-plugin-plugins-data-public.searchinterceptor.deps.md) | | <code>SearchInterceptorDeps</code> | |
| [getPendingCount$](./kibana-plugin-plugins-data-public.searchinterceptor.getpendingcount_.md) | | <code>() =&gt; Observable&lt;number&gt;</code> | Returns an <code>Observable</code> over the current number of pending searches. This could mean that one of the search requests is still in flight, or that it has only received partial responses. |
| [hideToast](./kibana-plugin-plugins-data-public.searchinterceptor.hidetoast.md) | | <code>() =&gt; void</code> | |
| [longRunningToast](./kibana-plugin-plugins-data-public.searchinterceptor.longrunningtoast.md) | | <code>Toast</code> | The current long-running toast (if there is one). |
| [pendingCount](./kibana-plugin-plugins-data-public.searchinterceptor.pendingcount.md) | | <code>number</code> | The number of pending search requests. |
| [pendingCount$](./kibana-plugin-plugins-data-public.searchinterceptor.pendingcount_.md) | | <code>BehaviorSubject&lt;number&gt;</code> | Observable that emits when the number of pending requests changes. |
| [requestTimeout](./kibana-plugin-plugins-data-public.searchinterceptor.requesttimeout.md) | | <code>number &#124; undefined</code> | |
| [showToast](./kibana-plugin-plugins-data-public.searchinterceptor.showtoast.md) | | <code>() =&gt; void</code> | |
| [timeoutSubscriptions](./kibana-plugin-plugins-data-public.searchinterceptor.timeoutsubscriptions.md) | | <code>Subscription</code> | The subscriptions from scheduling the automatic timeout for each request. |

## Methods

| Method | Modifiers | Description |
| --- | --- | --- |
| [getPendingCount$()](./kibana-plugin-plugins-data-public.searchinterceptor.getpendingcount_.md) | | Returns an <code>Observable</code> over the current number of pending searches. This could mean that one of the search requests is still in flight, or that it has only received partial responses. |
| [runSearch(request, signal, strategy)](./kibana-plugin-plugins-data-public.searchinterceptor.runsearch.md) | | |
| [search(request, options)](./kibana-plugin-plugins-data-public.searchinterceptor.search.md) | | Searches using the given <code>search</code> method. Overrides the <code>AbortSignal</code> with one that will abort either when <code>cancelPending</code> is called, when the request times out, or when the original <code>AbortSignal</code> is aborted. Updates the <code>pendingCount</code> when the request is started/finalized. |
| [search(request, options)](./kibana-plugin-plugins-data-public.searchinterceptor.search.md) | | Searches using the given <code>search</code> method. Overrides the <code>AbortSignal</code> with one that will abort either when <code>cancelPending</code> is called, when the request times out, or when the original <code>AbortSignal</code> is aborted. Updates <code>pendingCount$</code> when the request is started/finalized. |
| [setupTimers(options)](./kibana-plugin-plugins-data-public.searchinterceptor.setuptimers.md) | | |

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## SearchInterceptor.search() method

Searches using the given `search` method. Overrides the `AbortSignal` with one that will abort either when `cancelPending` is called, when the request times out, or when the original `AbortSignal` is aborted. Updates the `pendingCount` when the request is started/finalized.
Searches using the given `search` method. Overrides the `AbortSignal` with one that will abort either when `cancelPending` is called, when the request times out, or when the original `AbortSignal` is aborted. Updates `pendingCount$` when the request is started/finalized.

<b>Signature:</b>

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
http: CoreStart['http'];
http: CoreSetup['http'];
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export interface SearchInterceptorDeps

| Property | Type | Description |
| --- | --- | --- |
| [application](./kibana-plugin-plugins-data-public.searchinterceptordeps.application.md) | <code>ApplicationStart</code> | |
| [http](./kibana-plugin-plugins-data-public.searchinterceptordeps.http.md) | <code>CoreStart['http']</code> | |
| [toasts](./kibana-plugin-plugins-data-public.searchinterceptordeps.toasts.md) | <code>ToastsStart</code> | |
| [uiSettings](./kibana-plugin-plugins-data-public.searchinterceptordeps.uisettings.md) | <code>CoreStart['uiSettings']</code> | |
| [http](./kibana-plugin-plugins-data-public.searchinterceptordeps.http.md) | <code>CoreSetup['http']</code> | |
| [startServices](./kibana-plugin-plugins-data-public.searchinterceptordeps.startservices.md) | <code>Promise&lt;[CoreStart, any, unknown]&gt;</code> | |
| [toasts](./kibana-plugin-plugins-data-public.searchinterceptordeps.toasts.md) | <code>ToastsSetup</code> | |
| [uiSettings](./kibana-plugin-plugins-data-public.searchinterceptordeps.uisettings.md) | <code>CoreSetup['uiSettings']</code> | |
| [usageCollector](./kibana-plugin-plugins-data-public.searchinterceptordeps.usagecollector.md) | <code>SearchUsageCollector</code> | |

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; [SearchInterceptorDeps](./kibana-plugin-plugins-data-public.searchinterceptordeps.md) &gt; [application](./kibana-plugin-plugins-data-public.searchinterceptordeps.application.md)
[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [SearchInterceptorDeps](./kibana-plugin-plugins-data-public.searchinterceptordeps.md) &gt; [startServices](./kibana-plugin-plugins-data-public.searchinterceptordeps.startservices.md)

## SearchInterceptorDeps.application property
## SearchInterceptorDeps.startServices property

<b>Signature:</b>

```typescript
application: ApplicationStart;
startServices: Promise<[CoreStart, any, unknown]>;
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
toasts: ToastsStart;
toasts: ToastsSetup;
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
uiSettings: CoreStart['uiSettings'];
uiSettings: CoreSetup['uiSettings'];
```
1 change: 1 addition & 0 deletions src/plugins/data/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const createSetupContract = (): Setup => {
search: searchServiceMock.createSetupContract(),
fieldFormats: fieldFormatsServiceMock.createSetupContract(),
query: querySetupMock,
__enhance: jest.fn(),
};
};

Expand Down
18 changes: 12 additions & 6 deletions src/plugins/data/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
DataSetupDependencies,
DataStartDependencies,
InternalStartServices,
DataPublicPluginEnhancements,
} from './types';
import { AutocompleteService } from './autocomplete';
import { SearchService } from './search/search_service';
Expand Down Expand Up @@ -156,16 +157,21 @@ export class DataPublicPlugin
}))
);

const searchService = this.searchService.setup(core, {
expressions,
usageCollection,
getInternalStartServices,
packageInfo: this.packageInfo,
});

return {
autocomplete: this.autocomplete.setup(core),
search: this.searchService.setup(core, {
expressions,
usageCollection,
getInternalStartServices,
packageInfo: this.packageInfo,
}),
search: searchService,
fieldFormats: this.fieldFormatsService.setup(core),
query: queryService,
__enhance: (enhancements: DataPublicPluginEnhancements) => {
searchService.__enhance(enhancements.search);
},
};
}

Expand Down
35 changes: 22 additions & 13 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { $Values } from '@kbn/utility-types';
import _ from 'lodash';
import { Action } from 'history';
import { ApiResponse } from '@elastic/elasticsearch/lib/Transport';
import { ApplicationStart } from 'kibana/public';
import { Assign } from '@kbn/utility-types';
import { BehaviorSubject } from 'rxjs';
import Boom from 'boom';
import { Component } from 'react';
import { CoreSetup } from 'src/core/public';
import { CoreSetup as CoreSetup_2 } from 'kibana/public';
import { CoreStart } from 'kibana/public';
import { CoreStart as CoreStart_2 } from 'src/core/public';
import { Ensure } from '@kbn/utility-types';
Expand Down Expand Up @@ -65,7 +65,7 @@ import { SerializedFieldFormat as SerializedFieldFormat_2 } from 'src/plugins/ex
import { Subscription } from 'rxjs';
import { Toast } from 'kibana/public';
import { ToastInputFields } from 'src/core/public/notifications';
import { ToastsStart } from 'kibana/public';
import { ToastsSetup } from 'kibana/public';
import { TransportRequestOptions } from '@elastic/elasticsearch/lib/Transport';
import { TransportRequestParams } from '@elastic/elasticsearch/lib/Transport';
import { TransportRequestPromise } from '@elastic/elasticsearch/lib/Transport';
Expand Down Expand Up @@ -222,6 +222,10 @@ export type CustomFilter = Filter & {
//
// @public (undocumented)
export interface DataPublicPluginSetup {
// Warning: (ae-forgotten-export) The symbol "DataPublicPluginEnhancements" needs to be exported by the entry point index.d.ts
//
// @internal (undocumented)
__enhance: (enhancements: DataPublicPluginEnhancements) => void;
// Warning: (ae-forgotten-export) The symbol "AutocompleteSetup" needs to be exported by the entry point index.d.ts
//
// (undocumented)
Expand Down Expand Up @@ -1714,15 +1718,19 @@ export interface SearchError {
// @public (undocumented)
export class SearchInterceptor {
constructor(deps: SearchInterceptorDeps, requestTimeout?: number | undefined);
// @internal
protected abortController: AbortController;
// @internal (undocumented)
protected application: CoreStart['application'];
// (undocumented)
protected readonly deps: SearchInterceptorDeps;
getPendingCount$: () => Observable<number>;
// (undocumented)
getPendingCount$(): Observable<number>;
// @internal (undocumented)
protected hideToast: () => void;
// @internal
protected longRunningToast?: Toast;
// @internal
protected pendingCount$: BehaviorSubject<number>;
protected pendingCount: number;
// (undocumented)
protected readonly requestTimeout?: number | undefined;
// (undocumented)
Expand All @@ -1733,8 +1741,9 @@ export class SearchInterceptor {
combinedSignal: AbortSignal;
cleanup: () => void;
};
// (undocumented)
// @internal (undocumented)
protected showToast: () => void;
// @internal
protected timeoutSubscriptions: Subscription;
}

Expand All @@ -1743,13 +1752,13 @@ export class SearchInterceptor {
// @public (undocumented)
export interface SearchInterceptorDeps {
// (undocumented)
application: ApplicationStart;
http: CoreSetup_2['http'];
// (undocumented)
http: CoreStart['http'];
startServices: Promise<[CoreStart, any, unknown]>;
// (undocumented)
toasts: ToastsStart;
toasts: ToastsSetup;
// (undocumented)
uiSettings: CoreStart['uiSettings'];
uiSettings: CoreSetup_2['uiSettings'];
// Warning: (ae-forgotten-export) The symbol "SearchUsageCollector" needs to be exported by the entry point index.d.ts
//
// (undocumented)
Expand Down Expand Up @@ -1980,9 +1989,9 @@ export const UI_SETTINGS: {
// src/plugins/data/public/index.ts:393:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:396: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:54:5 - (ae-forgotten-export) The symbol "createFiltersFromValueClickAction" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/types.ts:55:5 - (ae-forgotten-export) The symbol "createFiltersFromRangeSelectAction" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/types.ts:63:5 - (ae-forgotten-export) The symbol "IndexPatternSelectProps" 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
// src/plugins/data/public/types.ts:71:5 - (ae-forgotten-export) The symbol "IndexPatternSelectProps" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
9 changes: 8 additions & 1 deletion src/plugins/data/public/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ export * from './aggs';
export * from './expressions';
export * from './tabify';

export { ISearch, ISearchOptions, ISearchGeneric, ISearchSetup, ISearchStart } from './types';
export {
ISearch,
ISearchOptions,
ISearchGeneric,
ISearchSetup,
ISearchStart,
SearchEnhancements,
} from './types';

export { IEsSearchResponse, IEsSearchRequest, ES_SEARCH_STRATEGY } from '../../common/search';

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/search/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ export * from './search_source/mocks';
function createSetupContract(): jest.Mocked<ISearchSetup> {
return {
aggs: searchAggsSetupMock(),
__enhance: jest.fn(),
};
}

function createStartContract(): jest.Mocked<ISearchStart> {
return {
aggs: searchAggsStartMock(),
setInterceptor: jest.fn(),
search: jest.fn(),
searchSource: searchSourceMock,
__LEGACY: {
Expand Down
Loading