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

[Search] Session SO polling #84225

Merged
merged 44 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1c82050
Monitor ids
Nov 24, 2020
52032fc
import fix
Nov 24, 2020
60abe6c
Merge remote-tracking branch 'upstream/master' into sessions/retry-logic
Nov 25, 2020
8a12991
solve circular dep
Nov 25, 2020
d692c1e
eslint
Nov 30, 2020
9a02d9c
Merge branch 'master' of github.com:elastic/kibana into sessions/retr…
Nov 30, 2020
1092c7a
mock circular dep
Nov 30, 2020
500f15d
max retries test
Nov 30, 2020
c6fea68
mock circular dep
Nov 30, 2020
e5325e9
test
Nov 30, 2020
c540fde
jest <(-:C
Dec 1, 2020
5f7db2d
jestttttt
Dec 1, 2020
80fdf82
Merge branch 'master' of github.com:elastic/kibana into sessions/retr…
Dec 1, 2020
4886819
[data.search] Move search method inside session service and add tests
lukasolson Dec 1, 2020
7387405
Merge branch 'master' of github.com:elastic/kibana into sessions/retr…
Dec 2, 2020
a91ea10
merge
Dec 2, 2020
0de7730
Move background session service to data_enhanced plugin
lukasolson Dec 2, 2020
5253b42
Merge branch 'master' of github.com:elastic/kibana into sessions/retr…
Dec 3, 2020
ec54b8b
Merge branch 'master' into search-session-search
lukasolson Dec 3, 2020
4ff6eaf
Merge branch 'search-session-search' into search-session-enhanced
lukasolson Dec 3, 2020
93128a1
Better logs
Dec 3, 2020
ea14d29
Fix types
lukasolson Dec 3, 2020
4ce9fef
Merge branch 'master' into search-session-enhanced
lukasolson Dec 3, 2020
7537e69
Merge branch 'master' into search-session-enhanced
kibanamachine Dec 3, 2020
53b8c32
Merge branch 'master' into search-session-enhanced
kibanamachine Dec 4, 2020
a0e2142
Space aware session service
Dec 6, 2020
54b440a
Merge branch 'master' of github.com:elastic/kibana into sessions/retr…
Dec 6, 2020
e8ec140
Merge remote-tracking branch 'lukasolson/search-session-enhanced' int…
Dec 6, 2020
149d94e
ts
Dec 6, 2020
0b875ac
Fix session service saving
Dec 7, 2020
f40fcca
Merge branch 'master' of github.com:elastic/kibana into sessions/retr…
Dec 7, 2020
c1ba50c
Merge remote-tracking branch 'upstream/master' into sessions/retry-logic
Dec 7, 2020
b5b0895
merge fix
Dec 7, 2020
f14f042
stable stringify
Dec 7, 2020
5b9782d
INMEM_MAX_SESSIONS
Dec 7, 2020
0858b98
INMEM_MAX_SESSIONS
Dec 7, 2020
6c9e345
Merge branch 'master' of github.com:elastic/kibana into sessions/retr…
Dec 8, 2020
e85da48
Merge branch 'sessions/retry-logic' of github.com:lizozom/kibana into…
Dec 8, 2020
4876f3d
Update x-pack/plugins/data_enhanced/server/search/session/session_ser…
lizozom Dec 8, 2020
ffabaa9
Update x-pack/plugins/data_enhanced/server/search/session/session_ser…
lizozom Dec 8, 2020
63c7d6a
Use setTimeout to schedule monitoring steps
Dec 8, 2020
51143af
Merge branch 'master' of github.com:elastic/kibana into sessions/retr…
Dec 8, 2020
bf54579
Merge branch 'master' of github.com:elastic/kibana into sessions/retr…
Dec 9, 2020
07fe4bf
settimeout
Dec 9, 2020
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [ISessionService](./kibana-plugin-plugins-data-server.isessionservice.md) &gt; [asScopedProvider](./kibana-plugin-plugins-data-server.isessionservice.asscopedprovider.md)

## ISessionService.asScopedProvider property

<b>Signature:</b>

```typescript
asScopedProvider: (core: CoreStart) => (request: KibanaRequest) => IScopedSessionService;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [ISessionService](./kibana-plugin-plugins-data-server.isessionservice.md)

## ISessionService interface

<b>Signature:</b>

```typescript
export interface ISessionService
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [asScopedProvider](./kibana-plugin-plugins-data-server.isessionservice.asscopedprovider.md) | <code>(core: CoreStart) =&gt; (request: KibanaRequest) =&gt; IScopedSessionService</code> | |

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
| [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) | |
| [OptionedParamType](./kibana-plugin-plugins-data-server.optionedparamtype.md) | |
| [Plugin](./kibana-plugin-plugins-data-server.plugin.md) | |
| [SessionService](./kibana-plugin-plugins-data-server.sessionservice.md) | The OSS session service. See data\_enhanced in X-Pack for the background session service. |

## Enumerations

Expand Down Expand Up @@ -54,6 +55,7 @@
| [ISearchSetup](./kibana-plugin-plugins-data-server.isearchsetup.md) | |
| [ISearchStart](./kibana-plugin-plugins-data-server.isearchstart.md) | |
| [ISearchStrategy](./kibana-plugin-plugins-data-server.isearchstrategy.md) | Search strategy interface contains a search method that takes in a request and returns a promise that resolves to a response. |
| [ISessionService](./kibana-plugin-plugins-data-server.isessionservice.md) | |
| [KueryNode](./kibana-plugin-plugins-data-server.kuerynode.md) | |
| [OptionedValueProp](./kibana-plugin-plugins-data-server.optionedvalueprop.md) | |
| [PluginSetup](./kibana-plugin-plugins-data-server.pluginsetup.md) | |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [SessionService](./kibana-plugin-plugins-data-server.sessionservice.md) &gt; [(constructor)](./kibana-plugin-plugins-data-server.sessionservice._constructor_.md)

## SessionService.(constructor)

Constructs a new instance of the `SessionService` class

<b>Signature:</b>

```typescript
constructor();
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [SessionService](./kibana-plugin-plugins-data-server.sessionservice.md) &gt; [asScopedProvider](./kibana-plugin-plugins-data-server.sessionservice.asscopedprovider.md)

## SessionService.asScopedProvider() method

<b>Signature:</b>

```typescript
asScopedProvider(core: CoreStart): (request: KibanaRequest) => {
search: <Request_1 extends IKibanaSearchRequest<any>, Response_1 extends IKibanaSearchResponse<any>>(strategy: ISearchStrategy<Request_1, Response_1>, request: Request_1, options: import("../../../common").ISearchOptions, deps: import("../types").SearchStrategyDependencies) => import("rxjs").Observable<Response_1>;
};
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| core | <code>CoreStart</code> | |

<b>Returns:</b>

`(request: KibanaRequest) => {
search: <Request_1 extends IKibanaSearchRequest<any>, Response_1 extends IKibanaSearchResponse<any>>(strategy: ISearchStrategy<Request_1, Response_1>, request: Request_1, options: import("../../../common").ISearchOptions, deps: import("../types").SearchStrategyDependencies) => import("rxjs").Observable<Response_1>;
}`

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

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [SessionService](./kibana-plugin-plugins-data-server.sessionservice.md)

## SessionService class

The OSS session service. See data\_enhanced in X-Pack for the background session service.

<b>Signature:</b>

```typescript
export declare class SessionService implements ISessionService
```

## Constructors

| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)()](./kibana-plugin-plugins-data-server.sessionservice._constructor_.md) | | Constructs a new instance of the <code>SessionService</code> class |

## Methods

| Method | Modifiers | Description |
| --- | --- | --- |
| [asScopedProvider(core)](./kibana-plugin-plugins-data-server.sessionservice.asscopedprovider.md) | | |
| [search(strategy, args)](./kibana-plugin-plugins-data-server.sessionservice.search.md) | | |

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

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [SessionService](./kibana-plugin-plugins-data-server.sessionservice.md) &gt; [search](./kibana-plugin-plugins-data-server.sessionservice.search.md)

## SessionService.search() method

<b>Signature:</b>

```typescript
search<Request extends IKibanaSearchRequest, Response extends IKibanaSearchResponse>(strategy: ISearchStrategy<Request, Response>, ...args: Parameters<ISearchStrategy<Request, Response>['search']>): import("rxjs").Observable<Response>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| strategy | <code>ISearchStrategy&lt;Request, Response&gt;</code> | |
| args | <code>Parameters&lt;ISearchStrategy&lt;Request, Response&gt;['search']&gt;</code> | |

<b>Returns:</b>

`import("rxjs").Observable<Response>`

Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

import Chance from 'chance';

import { getUpgradeableConfigMock } from './get_upgradeable_config.test.mock';
import { SavedObjectsErrorHelpers } from '../../saved_objects';
import { savedObjectsClientMock } from '../../saved_objects/service/saved_objects_client.mock';
import { loggingSystemMock } from '../../logging/logging_system.mock';
import { getUpgradeableConfigMock } from './get_upgradeable_config.test.mock';

import { createOrUpgradeSavedConfig } from './create_or_upgrade_saved_config';

Expand Down
1 change: 0 additions & 1 deletion src/plugins/data/common/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ export * from './expressions';
export * from './search_source';
export * from './tabify';
export * from './types';
export * from './session';
export * from './utils';
21 changes: 0 additions & 21 deletions src/plugins/data/common/search/session/index.ts

This file was deleted.

26 changes: 0 additions & 26 deletions src/plugins/data/common/search/session/status.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ import { SavedObject } from 'kibana/server';
import { SavedObject as SavedObject_2 } from 'src/core/server';
import { SavedObjectReference } from 'src/core/types';
import { SavedObjectsClientContract } from 'src/core/public';
import { SavedObjectsFindOptions } from 'kibana/public';
import { SavedObjectsFindResponse } from 'kibana/server';
import { Search } from '@elastic/elasticsearch/api/requestParams';
import { SearchResponse } from 'elasticsearch';
Expand Down
16 changes: 5 additions & 11 deletions src/plugins/data/public/search/session/sessions_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
*/

import { PublicContract } from '@kbn/utility-types';
import { HttpSetup } from 'kibana/public';
import { HttpSetup, SavedObjectsFindOptions } from 'kibana/public';
import type { SavedObject, SavedObjectsFindResponse } from 'kibana/server';
import { BackgroundSessionSavedObjectAttributes, SearchSessionFindOptions } from '../../../common';

export type ISessionsClient = PublicContract<SessionsClient>;
export interface SessionsClientDeps {
Expand All @@ -37,7 +36,7 @@ export class SessionsClient {
this.http = deps.http;
}

public get(sessionId: string): Promise<SavedObject<BackgroundSessionSavedObjectAttributes>> {
public get(sessionId: string): Promise<SavedObject> {
return this.http.get(`/internal/session/${encodeURIComponent(sessionId)}`);
}

Expand All @@ -55,7 +54,7 @@ export class SessionsClient {
restoreState: Record<string, unknown>;
urlGeneratorId: string;
sessionId: string;
}): Promise<SavedObject<BackgroundSessionSavedObjectAttributes>> {
}): Promise<SavedObject> {
return this.http.post(`/internal/session`, {
body: JSON.stringify({
name,
Expand All @@ -68,18 +67,13 @@ export class SessionsClient {
});
}

public find(
options: SearchSessionFindOptions
): Promise<SavedObjectsFindResponse<BackgroundSessionSavedObjectAttributes>> {
public find(options: SavedObjectsFindOptions): Promise<SavedObjectsFindResponse> {
return this.http!.post(`/internal/session`, {
body: JSON.stringify(options),
});
}

public update(
sessionId: string,
attributes: Partial<BackgroundSessionSavedObjectAttributes>
): Promise<SavedObject<BackgroundSessionSavedObjectAttributes>> {
public update(sessionId: string, attributes: unknown): Promise<SavedObject> {
return this.http!.put(`/internal/session/${encodeURIComponent(sessionId)}`, {
body: JSON.stringify(attributes),
});
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/data/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ export {
searchUsageObserver,
shimAbortSignal,
SearchUsage,
SessionService,
ISessionService,
} from './search';

// Search namespace
Expand Down
1 change: 0 additions & 1 deletion src/plugins/data/server/saved_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ export { querySavedObjectType } from './query';
export { indexPatternSavedObjectType } from './index_patterns';
export { kqlTelemetry } from './kql_telemetry';
export { searchTelemetry } from './search_telemetry';
export { BACKGROUND_SESSION_TYPE, backgroundSessionMapping } from './background_session';
1 change: 1 addition & 0 deletions src/plugins/data/server/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ export * from './es_search';
export { usageProvider, SearchUsage, searchUsageObserver } from './collectors';
export * from './aggs';
export { shimHitsTotal } from './routes';
export * from './session';
21 changes: 0 additions & 21 deletions src/plugins/data/server/search/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
* under the License.
*/

import type { RequestHandlerContext } from 'src/core/server';
import { coreMock } from '../../../../core/server/mocks';
import { ISearchSetup, ISearchStart } from './types';
import { searchAggsSetupMock, searchAggsStartMock } from './aggs/mocks';
import { searchSourceMock } from './search_source/mocks';
Expand All @@ -42,22 +40,3 @@ export function createSearchStartMock(): jest.Mocked<ISearchStart> {
searchSource: searchSourceMock.createStartContract(),
};
}

export function createSearchRequestHandlerContext(): jest.Mocked<RequestHandlerContext> {
return {
core: coreMock.createRequestHandlerContext(),
search: {
search: jest.fn(),
cancel: jest.fn(),
session: {
save: jest.fn(),
get: jest.fn(),
find: jest.fn(),
update: jest.fn(),
delete: jest.fn(),
trackId: jest.fn(),
getId: jest.fn(),
},
},
};
}
Loading