-
Notifications
You must be signed in to change notification settings - Fork 118
/
stream-metrics.ts
63 lines (55 loc) · 1.52 KB
/
stream-metrics.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
export const TYPE = 'spring.cloud.dataflow.stream.app.type';
export const INSTANCE_COUNT = 'spring.cloud.stream.instanceCount';
/**
* StreamStatuses and related model classes
*
* @author Alex Boyko
*/
export class InstanceStatus {
guid: string;
index: number;
state: string;
static fromJSON(input): InstanceStatus {
const instanceStatus = new InstanceStatus();
instanceStatus.guid = input.guid;
instanceStatus.index = input.index;
instanceStatus.state = input.state;
return instanceStatus;
}
}
export class StreamStatus {
name: string;
id: string;
instances: InstanceStatus[];
static fromJSON(input) {
const streamStatus = new StreamStatus();
streamStatus.id = input.id;
streamStatus.name = input.name;
if (Array.isArray(input.instances)) {
streamStatus.instances = input.instances.map(InstanceStatus.fromJSON);
} else {
streamStatus.instances = [];
}
return streamStatus;
}
}
export class StreamStatuses {
name: string;
applications: StreamStatus[];
static fromJSON(input): StreamStatuses {
const streamStatuses = new StreamStatuses();
streamStatuses.name = input.name;
if (Array.isArray(input.applications)) {
streamStatuses.applications = input.applications.map(StreamStatus.fromJSON);
} else {
streamStatuses.applications = [];
}
return streamStatuses;
}
static listFromJSON(input): Array<StreamStatuses> {
if (Array.isArray(input)) {
return input.map(StreamStatuses.fromJSON);
}
return [];
}
}