Skip to content

Commit

Permalink
fix: tweak polling constants to improve perf (#459)
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin authored and mrmeku committed Jan 7, 2019
1 parent f76979f commit 93a62ed
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
4 changes: 2 additions & 2 deletions libs/server/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,14 @@ export function normalizePath(value: string): string {
* * the list of local files
* * json files from node_modules we are likely to read
*
* both the data sets get updated every 30 seconds.
* both the data sets get updated every 60 seconds.
*/
export function cacheFiles(p: string) {
setTimeout(() => {
files[p] = listFiles(p);
fileContents = cacheJsonFiles(p);
setTimeout(() => {
cacheFiles(p);
}, 30000);
}, 60000);
}, 0);
}
32 changes: 23 additions & 9 deletions libs/utils/src/lib/command-runner.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import {
takeWhile,
first,
flatMap,
withLatestFrom
withLatestFrom,
switchMap
} from 'rxjs/operators';
import { COMMANDS_POLLING } from './polling-constants';
import { COMMAND_LIST_POLLING, COMMANDS_POLLING } from './polling-constants';
import { ContextualActionBarService } from '@nrwl/angular-console-enterprise-frontend';
import {
CommandsGQL,
Expand Down Expand Up @@ -55,6 +56,7 @@ export interface CommandResponse {
export class CommandRunner {
readonly activeCommand$ = new BehaviorSubject(false);
activeCommandId: string;
readonly refreshList$ = new BehaviorSubject(null);

constructor(
private readonly getCommandGQL: GetCommandGQL,
Expand Down Expand Up @@ -119,9 +121,13 @@ export class CommandRunner {
}

listAllCommands(): Observable<ListAllCommands.Commands[]> {
return this.listAllCommandsGQL
.watch({}, { pollInterval: COMMANDS_POLLING })
.valueChanges.pipe(map(r => r.data.commands));
return this.refreshList$.pipe(
switchMap(() => {
return this.listAllCommandsGQL
.watch({}, { pollInterval: COMMAND_LIST_POLLING })
.valueChanges.pipe(map(r => r.data.commands));
})
);
}

getCommand(
Expand Down Expand Up @@ -156,7 +162,9 @@ export class CommandRunner {
.mutate({
id
})
.subscribe(() => {});
.subscribe(() => {
this.refreshList$.next(null);
});
}

stopCommandViaCtrlC(id: string) {
Expand All @@ -168,23 +176,29 @@ export class CommandRunner {
}

removeAllCommands() {
return this.removeAllCommandsGQL.mutate().subscribe(() => {});
return this.removeAllCommandsGQL.mutate().subscribe(() => {
this.refreshList$.next(null);
});
}

removeCommand(id: string) {
return this.removeCommandGQL
.mutate({
id
})
.subscribe(() => {});
.subscribe(() => {
this.refreshList$.next(null);
});
}

restartCommand(id: string) {
return this.restartCommandGQL
.mutate({
id
})
.subscribe(() => {});
.subscribe(() => {
this.refreshList$.next(null);
});
}

stopActiveCommand() {
Expand Down
13 changes: 7 additions & 6 deletions libs/utils/src/lib/polling-constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export const COMMANDS_POLLING = 150;
export const NODE_JS_INSTALL_POLLING = 150;
export const COMMANDS_POLLING = 250;
export const COMMAND_LIST_POLLING = 1000;
export const NODE_JS_INSTALL_POLLING = 250;
export const BASIC_WORKSPACE_POLLING = 5000;
export const PROJECTS_POLLING = 5000;
export const TARGET_POLLING = 5000;
export const SCHEMATICS_POLLING = 5000;
export const EXTENSIONS_POLLING = 5000;
export const PROJECTS_POLLING = 15000;
export const TARGET_POLLING = 30000;
export const SCHEMATICS_POLLING = 30000;
export const EXTENSIONS_POLLING = 30000;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"appId": "io.nrwl.AngularConsole",
"productName": "Angular Console",
"copyright": "Copyright © 2018 Narwhal Technologies Inc",
"asar": true,
"asar": false,
"extraResources": [
{
"from": "dist/apps/electron/assets",
Expand Down

0 comments on commit 93a62ed

Please sign in to comment.