mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
not abstract, give default
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
8ae55e6135
commit
7a792127d2
@ -11,8 +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 readonly abstract limit: number;
|
public readonly limit?: number;
|
||||||
public readonly abstract saveLimit: number;
|
public readonly bufferSize: number = 50000;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@ -20,6 +20,16 @@ export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemSt
|
|||||||
kubeWatchApi.addListener(this, this.onWatchApiEvent);
|
kubeWatchApi.addListener(this, this.onWatchApiEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get query(): IKubeApiQueryParams {
|
||||||
|
const { limit } = this;
|
||||||
|
|
||||||
|
if (!limit) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return { limit };
|
||||||
|
}
|
||||||
|
|
||||||
getStatuses?(items: T[]): Record<string, number>;
|
getStatuses?(items: T[]): Record<string, number>;
|
||||||
|
|
||||||
getAllByNs(namespace: string | string[], strict = false): T[] {
|
getAllByNs(namespace: string | string[], strict = false): T[] {
|
||||||
@ -63,10 +73,7 @@ export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemSt
|
|||||||
|
|
||||||
protected async loadItems(allowedNamespaces?: string[]): Promise<T[]> {
|
protected async loadItems(allowedNamespaces?: string[]): Promise<T[]> {
|
||||||
if (!this.api.isNamespaced || !allowedNamespaces) {
|
if (!this.api.isNamespaced || !allowedNamespaces) {
|
||||||
const { limit } = this;
|
return this.api.list({}, this.query);
|
||||||
const query: IKubeApiQueryParams = limit ? { limit } : {};
|
|
||||||
|
|
||||||
return this.api.list({}, query);
|
|
||||||
} else {
|
} else {
|
||||||
return Promise
|
return Promise
|
||||||
.all(allowedNamespaces.map(namespace => this.api.list({ namespace })))
|
.all(allowedNamespaces.map(namespace => this.api.list({ namespace })))
|
||||||
@ -208,6 +215,6 @@ export abstract class KubeObjectStore<T extends KubeObject = any> extends ItemSt
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update items
|
// update items
|
||||||
this.items.replace(this.sortItems(items.slice(-this.saveLimit)));
|
this.items.replace(this.sortItems(items.slice(-this.bufferSize)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user