2017-12-15 21:39:18 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import { computed } from '@ember/object';
|
2017-09-19 14:47:10 +00:00
|
|
|
import Model from 'ember-data/model';
|
|
|
|
import attr from 'ember-data/attr';
|
2020-06-10 13:49:16 +00:00
|
|
|
import classic from 'ember-classic-decorator';
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@classic
|
|
|
|
export default class Agent extends Model {
|
|
|
|
@service system;
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@attr('string') name;
|
|
|
|
@attr('string') address;
|
|
|
|
@attr('string') serfPort;
|
|
|
|
@attr('string') rpcPort;
|
|
|
|
@attr({ defaultValue: () => ({}) }) tags;
|
|
|
|
@attr('string') status;
|
|
|
|
@attr('string') datacenter;
|
|
|
|
@attr('string') region;
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@computed('address', 'port')
|
|
|
|
get rpcAddr() {
|
2019-03-26 07:46:44 +00:00
|
|
|
const { address, rpcPort } = this;
|
2017-09-19 14:47:10 +00:00
|
|
|
return address && rpcPort && `${address}:${rpcPort}`;
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@computed('system.leader.rpcAddr')
|
|
|
|
get isLeader() {
|
2019-03-26 07:46:44 +00:00
|
|
|
return this.get('system.leader.rpcAddr') === this.rpcAddr;
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
|
|
|
}
|