store more than largest kube api request amount in the event store

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2020-12-02 10:13:30 -05:00
1 parent b128f55006
commit 8ae55e6135
2 files changed
+6 -9

No files matched your search

@@ -12,6 +12,7 @@ import { apiManager } from "../../api/api-manager";
export class EventStore extends KubeObjectStore<KubeEvent> { export class EventStore extends KubeObjectStore<KubeEvent> {
api = eventApi; api = eventApi;
limit = 1000; limit = 1000;
saveLimit = 50000;
protected bindWatchEventsUpdater() { protected bindWatchEventsUpdater() {
return super.bindWatchEventsUpdater(5000); return super.bindWatchEventsUpdater(5000);
+5 -9
View File
@@ -11,7 +11,8 @@ import { getHostedCluster } from "../common/cluster-store";
@autobind() @autobind()
export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemStore<T> { export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemStore<T> {
abstract api: KubeApi<T>; abstract api: KubeApi<T>;
public limit: number; public readonly abstract limit: number;
public readonly abstract saveLimit: number;
constructor() { constructor() {
super(); super();
@@ -179,9 +180,9 @@ export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemSt
return; return;
} }
// create latest non-observable copy of items to apply updates in one action (==single render) // create latest non-observable copy of items to apply updates in one action (==single render)
let items = this.items.toJS(); const items = this.items.toJS();
this.eventsBuffer.clear().forEach(({ type, object }) => { for (const {type, object} of this.eventsBuffer.clear()) {
const { uid, selfLink } = object.metadata; const { uid, selfLink } = object.metadata;
const index = items.findIndex(item => item.getId() === uid); const index = items.findIndex(item => item.getId() === uid);
const item = items[index]; const item = items[index];
@@ -204,14 +205,9 @@ export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemSt
} }
break; break;
} }
});
// slice to max allowed items
if (this.limit && items.length > this.limit) {
items = items.slice(-this.limit);
} }
// update items // update items
this.items.replace(this.sortItems(items)); this.items.replace(this.sortItems(items.slice(-this.saveLimit)));
} }
} }