Throttle journalctl restarts

This addresses an issue with typeahead search generating a significant
load on the system, a single filter test run can make ~100 calls to
journalctl restart if not throttled.
This commit is contained in:
Justin Stephenson 2021-07-07 10:24:52 -04:00
parent 6379950582
commit d038d2bd55
2 changed files with 8 additions and 2 deletions

View file

@ -58,6 +58,7 @@
"raw-loader": "^0.5.1", "raw-loader": "^0.5.1",
"react": "16.13.1", "react": "16.13.1",
"react-dom": "16.13.1", "react-dom": "16.13.1",
"throttle-debounce": "2.3.0",
"xterm": "^3.14.5" "xterm": "^3.14.5"
} }
} }

View file

@ -58,6 +58,7 @@ import {
SearchIcon SearchIcon
} from "@patternfly/react-icons"; } from "@patternfly/react-icons";
import { global_danger_color_200 } from "@patternfly/react-tokens"; import { global_danger_color_200 } from "@patternfly/react-tokens";
import { debounce } from 'throttle-debounce';
const $ = require("jquery"); const $ = require("jquery");
const cockpit = require("cockpit"); const cockpit = require("cockpit");
@ -741,6 +742,11 @@ export default class View extends React.Component {
this.setState({ recordingList: [] }); this.setState({ recordingList: [] });
} }
throttleJournalRestart = debounce(300, () => {
this.clearRecordings();
this.journalctlRestart();
});
handleInputChange(name, value) { handleInputChange(name, value) {
const state = {}; const state = {};
state[name] = value; state[name] = value;
@ -793,8 +799,7 @@ export default class View extends React.Component {
this.state.hostname !== prevState.hostname || this.state.hostname !== prevState.hostname ||
this.state.search !== prevState.search this.state.search !== prevState.search
) { ) {
this.clearRecordings(); this.throttleJournalRestart();
this.journalctlRestart();
} }
} }