Skip to main content

ResourceWatcher

@webda/kubernetes


Class: ResourceWatcher

Defined in: kubernetes/src/stores/watcher.ts:17

Emit the repository events of the changes made to the resources of a root model by others than this process (kubectl, GitOps, another replica)

The objects listed at start are known silently; afterwards an added object emits Created, a change of its data (spec, status fields, model) Updated and a deletion Deleted, on the repository of the object's model. Changes of metadata only (finalizers, operator conditions) and the writes of this process emit nothing.

Constructors​

Constructor​

new ResourceWatcher(store, root, resources, onError): ResourceWatcher

Defined in: kubernetes/src/stores/watcher.ts:29

Parameters​

store​

KubernetesStore

the store

root​

ModelClass

the model owning the resources

resources​

CustomResources

the resources, with the tracker of this process writes

onError​

(err) => void

called when the watch fails (it restarts)

Returns​

ResourceWatcher

Properties​

informer?​

protected optional informer?: KubernetesInformer<CustomResource>

Defined in: kubernetes/src/stores/watcher.ts:18


onError​

protected onError: (err) => void

Defined in: kubernetes/src/stores/watcher.ts:33

called when the watch fails (it restarts)

Parameters​

err​

unknown

Returns​

void


repositories​

protected repositories: Map<string, { events: Repository<any>; raw: KubernetesRepository<any>; }>

Defined in: kubernetes/src/stores/watcher.ts:21


resources​

protected resources: CustomResources

Defined in: kubernetes/src/stores/watcher.ts:32

the resources, with the tracker of this process writes


root​

protected root: ModelClass

Defined in: kubernetes/src/stores/watcher.ts:31

the model owning the resources


rows​

protected rows: Map<string, string>

Defined in: kubernetes/src/stores/watcher.ts:20

data of each known object, to detect the changes of the model data


store​

protected store: KubernetesStore

Defined in: kubernetes/src/stores/watcher.ts:30

the store

Methods​

onChange()​

protected onChange(resource, live): Promise<void>

Defined in: kubernetes/src/stores/watcher.ts:94

An object was added or changed

Parameters​

resource​

CustomResource

the resource

live​

boolean

false while listing the existing objects

Returns​

Promise<void>


onDelete()​

protected onDelete(resource): Promise<void>

Defined in: kubernetes/src/stores/watcher.ts:117

An object was deleted

Parameters​

resource​

CustomResource

the last state of the resource

Returns​

Promise<void>


repositoriesOf()​

protected repositoriesOf(resource): object

Defined in: kubernetes/src/stores/watcher.ts:71

Repositories of the model of a resource: the model in its annotation when this store holds it under the root, else the root model

Parameters​

resource​

CustomResource

the resource

Returns​

object

the repository emitting the events and the one converting the resource

events​

events: Repository<any>

raw​

raw: KubernetesRepository<any>


start()​

start(): Promise<void>

Defined in: kubernetes/src/stores/watcher.ts:40

Start watching

Returns​

Promise<void>

once the resources are listed


stop()​

stop(): Promise<void>

Defined in: kubernetes/src/stores/watcher.ts:59

Stop watching

Returns​

Promise<void>