Skip to content

Commit

Permalink
[Search] Session SO polling (#84225)
Browse files Browse the repository at this point in the history
* Monitor ids

* import fix

* solve circular dep

* eslint

* mock circular dep

* max retries test

* mock circular dep

* test

* jest <(-:C

* jestttttt

* [data.search] Move search method inside session service and add tests

* merge

* Move background session service to data_enhanced plugin

* Better logs
Save IDs only in monitoring loop

* Fix types

* Space aware session service

* ts

* Fix session service saving

* merge fix

* stable stringify

* INMEM_MAX_SESSIONS

* INMEM_MAX_SESSIONS

* Update x-pack/plugins/data_enhanced/server/search/session/session_service.ts

Co-authored-by: Anton Dosov <dosantappdev@gmail.com>

* Update x-pack/plugins/data_enhanced/server/search/session/session_service.ts

Co-authored-by: Anton Dosov <dosantappdev@gmail.com>

* Use setTimeout to schedule monitoring steps

* settimeout

Co-authored-by: Lukas Olson <olson.lukas@gmail.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Anton Dosov <dosantappdev@gmail.com>
  • Loading branch information
4 people committed Dec 9, 2020
1 parent 58fc711 commit 0a04835
Show file tree
Hide file tree
Showing 10 changed files with 479 additions and 25 deletions.
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
6 changes: 4 additions & 2 deletions src/plugins/data/server/search/search_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@ export class SearchService implements Plugin<ISearchSetup, ISearchStart> {
private readonly searchSourceService = new SearchSourceService();
private defaultSearchStrategyName: string = ES_SEARCH_STRATEGY;
private searchStrategies: StrategyMap = {};
private sessionService: ISessionService;
private coreStart?: CoreStart;
private sessionService: ISessionService = new SessionService();

constructor(
private initializerContext: PluginInitializerContext<ConfigSchema>,
private readonly logger: Logger
) {}
) {
this.sessionService = new SessionService();
}

public setup(
core: CoreSetup<{}, DataPluginStart>,
Expand Down
13 changes: 10 additions & 3 deletions x-pack/plugins/data_enhanced/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface SetupDependencies {

export class EnhancedDataServerPlugin implements Plugin<void, void, SetupDependencies> {
private readonly logger: Logger;
private sessionService!: BackgroundSessionService;

constructor(private initializerContext: PluginInitializerContext) {
this.logger = initializerContext.logger.get('data_enhanced');
Expand All @@ -53,20 +54,26 @@ export class EnhancedDataServerPlugin implements Plugin<void, void, SetupDepende
eqlSearchStrategyProvider(this.logger)
);

this.sessionService = new BackgroundSessionService(this.logger);

deps.data.__enhance({
search: {
defaultStrategy: ENHANCED_ES_SEARCH_STRATEGY,
sessionService: new BackgroundSessionService(),
sessionService: this.sessionService,
},
});

const router = core.http.createRouter();
registerSessionRoutes(router);
}

public start(core: CoreStart) {}
public start(core: CoreStart) {
this.sessionService.start(core, this.initializerContext.config.create());
}

public stop() {}
public stop() {
this.sessionService.stop();
}
}

export { EnhancedDataServerPlugin as Plugin };
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export const backgroundSessionMapping: SavedObjectsType = {
hidden: true,
mappings: {
properties: {
sessionId: {
type: 'keyword',
},
name: {
type: 'keyword',
},
Expand Down
Loading

0 comments on commit 0a04835

Please sign in to comment.