diff --git a/src/renderer/kube-object.store.ts b/src/renderer/kube-object.store.ts index 2fd33b24b7..13d0b8ce8b 100644 --- a/src/renderer/kube-object.store.ts +++ b/src/renderer/kube-object.store.ts @@ -11,8 +11,8 @@ import { getHostedCluster } from "../common/cluster-store"; @autobind() export abstract class KubeObjectStore extends ItemStore { abstract api: KubeApi; - public readonly abstract limit: number; - public readonly abstract saveLimit: number; + public readonly limit?: number; + public readonly bufferSize: number = 50000; constructor() { super(); @@ -20,6 +20,16 @@ export abstract class KubeObjectStore extends ItemSt kubeWatchApi.addListener(this, this.onWatchApiEvent); } + get query(): IKubeApiQueryParams { + const { limit } = this; + + if (!limit) { + return {}; + } + + return { limit }; + } + getStatuses?(items: T[]): Record; getAllByNs(namespace: string | string[], strict = false): T[] { @@ -63,10 +73,7 @@ export abstract class KubeObjectStore extends ItemSt protected async loadItems(allowedNamespaces?: string[]): Promise { if (!this.api.isNamespaced || !allowedNamespaces) { - const { limit } = this; - const query: IKubeApiQueryParams = limit ? { limit } : {}; - - return this.api.list({}, query); + return this.api.list({}, this.query); } else { return Promise .all(allowedNamespaces.map(namespace => this.api.list({ namespace }))) @@ -208,6 +215,6 @@ export abstract class KubeObjectStore extends ItemSt } // update items - this.items.replace(this.sortItems(items.slice(-this.saveLimit))); + this.items.replace(this.sortItems(items.slice(-this.bufferSize))); } }