mirror of https://github.com/status-im/consul.git
Update peer repo with latest API changes
This commit is contained in:
parent
d17af23641
commit
454424145a
|
@ -16,7 +16,17 @@ export default class Peer extends Model {
|
|||
@attr('string') Name;
|
||||
@attr('string') State;
|
||||
@attr('string') ID;
|
||||
@attr('number') ImportedServiceCount;
|
||||
@attr('number') ExportedServiceCount;
|
||||
@attr() ImportedServices;
|
||||
@attr() ExportedServices;
|
||||
@attr('date') LastHeartbeat;
|
||||
@attr('date') LastReceive;
|
||||
@attr('date') LastSend;
|
||||
@attr() PeerServerAddresses;
|
||||
|
||||
get ImportedServiceCount() {
|
||||
return this.ImportedServices.length;
|
||||
}
|
||||
get ExportedServiceCount() {
|
||||
return this.ExportedServices.length;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,22 @@
|
|||
import RepositoryService from 'consul-ui/services/repository';
|
||||
import dataSource from 'consul-ui/decorators/data-source';
|
||||
|
||||
function normalizePeerPayload(peerPayload, dc, partition) {
|
||||
const {
|
||||
StreamStatus: { LastHeartbeat, LastReceive, LastSend, ImportedServices, ExportedServices },
|
||||
} = peerPayload;
|
||||
|
||||
return {
|
||||
...peerPayload,
|
||||
LastHeartbeat,
|
||||
LastReceive,
|
||||
LastSend,
|
||||
ImportedServices,
|
||||
ExportedServices,
|
||||
Datacenter: dc,
|
||||
Partition: partition,
|
||||
};
|
||||
}
|
||||
export default class PeerService extends RepositoryService {
|
||||
getModelName() {
|
||||
return 'peer';
|
||||
|
@ -39,11 +55,7 @@ export default class PeerService extends RepositoryService {
|
|||
},
|
||||
body: body.map((item) => {
|
||||
return cache(
|
||||
{
|
||||
...item,
|
||||
Datacenter: dc,
|
||||
Partition: partition,
|
||||
},
|
||||
normalizePeerPayload(item),
|
||||
(uri) => uri`peer:///${partition}/${ns}/${dc}/peer/${item.Name}`
|
||||
);
|
||||
}),
|
||||
|
@ -80,11 +92,7 @@ export default class PeerService extends RepositoryService {
|
|||
uri: uri,
|
||||
},
|
||||
body: cache(
|
||||
{
|
||||
...body,
|
||||
Datacenter: dc,
|
||||
Partition: partition,
|
||||
},
|
||||
normalizePeerPayload(body),
|
||||
(uri) => uri`peer:///${partition}/${ns}/${dc}/peer/${body.Name}`
|
||||
),
|
||||
};
|
||||
|
|
|
@ -18,8 +18,13 @@
|
|||
'TERMINATED',
|
||||
'UNDEFINED'
|
||||
])}",
|
||||
"ImportedServiceCount": ${fake.random.number({min: 0, max: 4000})},
|
||||
"ExportedServiceCount": ${fake.random.number({min: 0, max: 4000})},
|
||||
"StreamStatus": {
|
||||
"LastHeartbeat": "${fake.date.past(10).toISOString()}",
|
||||
"LastReceive": "${fake.date.past(10).toISOString()}",
|
||||
"LastSend": "${fake.date.past(10).toISOString()}",
|
||||
"ExportedServices": ["${`export-service-${i}`}"],
|
||||
"ImportedServices": ["${`import-service-${i}`}"]
|
||||
},
|
||||
"PeerID": "${id}",
|
||||
"PeerServerName": "${fake.internet.domainName()}",
|
||||
"PeerServerAddresses": [
|
||||
|
|
Loading…
Reference in New Issue