1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

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 2020-12-01 16:28:10 -05:00
parent b128f55006
commit 8ae55e6135
2 changed files with 6 additions and 9 deletions

View File

@ -12,6 +12,7 @@ import { apiManager } from "../../api/api-manager";
export class EventStore extends KubeObjectStore<KubeEvent> {
api = eventApi;
limit = 1000;
saveLimit = 50000;
protected bindWatchEventsUpdater() {
return super.bindWatchEventsUpdater(5000);

View File

@ -11,7 +11,8 @@ import { getHostedCluster } from "../common/cluster-store";
@autobind()
export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemStore<T> {
abstract api: KubeApi<T>;
public limit: number;
public readonly abstract limit: number;
public readonly abstract saveLimit: number;
constructor() {
super();
@ -179,9 +180,9 @@ export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemSt
return;
}
// 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 index = items.findIndex(item => item.getId() === uid);
const item = items[index];
@ -204,14 +205,9 @@ export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemSt
}
break;
}
});
// slice to max allowed items
if (this.limit && items.length > this.limit) {
items = items.slice(-this.limit);
}
// update items
this.items.replace(this.sortItems(items));
this.items.replace(this.sortItems(items.slice(-this.saveLimit)));
}
}