|
|
|
@@ -59,15 +59,14 @@ func NewAppState() *AppState { |
|
|
|
Uptime: 0, |
|
|
|
ActiveReaders: []string{}, |
|
|
|
ActiveWriters: []string{}, |
|
|
|
ActiveBeacons: []string{}, |
|
|
|
}, |
|
|
|
ActiveBeacons: []string{}, |
|
|
|
}, |
|
|
|
Decoder: DecoderHealth{ |
|
|
|
BaseHealth: BaseHealth{ |
|
|
|
Uptime: 0, |
|
|
|
ActiveReaders: []string{}, |
|
|
|
ActiveWriters: []string{}, |
|
|
|
ActiveBeacons: []string{}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
Bridge: BridgeHealth{ |
|
|
|
@@ -75,8 +74,8 @@ func NewAppState() *AppState { |
|
|
|
Uptime: 0, |
|
|
|
ActiveReaders: []string{}, |
|
|
|
ActiveWriters: []string{}, |
|
|
|
ActiveBeacons: []string{}, |
|
|
|
}, |
|
|
|
ActiveBeacons: []string{}, |
|
|
|
}, |
|
|
|
Kafka: ServiceStatus{Status: "unknown"}, |
|
|
|
Database: ServiceStatus{Status: "unknown"}, |
|
|
|
@@ -117,10 +116,14 @@ func (m *AppState) UpdateServerHealth(kafka, database ServiceStatus) { |
|
|
|
} |
|
|
|
|
|
|
|
func (m *AppState) GetLocationHealth(k *kafkaclient.KafkaManager) ([]byte, error) { |
|
|
|
beacons := m.GetAllBeacons() |
|
|
|
m.health.Location.ActiveBeacons = make([]string, 0, len(beacons)) |
|
|
|
for beacon := range beacons { |
|
|
|
m.health.Location.ActiveBeacons = append(m.health.Location.ActiveBeacons, beacon) |
|
|
|
} |
|
|
|
m.health.Location.GetUptime(m.startTime) |
|
|
|
m.health.Location.GetActiveReaders(k) |
|
|
|
m.health.Location.GetActiveWriters(k) |
|
|
|
m.health.Location.GetActiveBeacons(m) |
|
|
|
return m.health.Location.Marshal() |
|
|
|
} |
|
|
|
|
|
|
|
@@ -128,15 +131,18 @@ func (m *AppState) GetDecoderHealth(k *kafkaclient.KafkaManager) ([]byte, error) |
|
|
|
m.health.Decoder.GetUptime(m.startTime) |
|
|
|
m.health.Decoder.GetActiveReaders(k) |
|
|
|
m.health.Decoder.GetActiveWriters(k) |
|
|
|
m.health.Decoder.GetActiveBeacons(m) |
|
|
|
return m.health.Decoder.Marshal() |
|
|
|
} |
|
|
|
|
|
|
|
func (m *AppState) GetBridgeHealth(k *kafkaclient.KafkaManager) ([]byte, error) { |
|
|
|
beacons := m.GetBeaconLookup() |
|
|
|
m.health.Bridge.ActiveBeacons = make([]string, 0, len(beacons)) |
|
|
|
for beacon := range beacons { |
|
|
|
m.health.Bridge.ActiveBeacons = append(m.health.Bridge.ActiveBeacons, beacon) |
|
|
|
} |
|
|
|
m.health.Bridge.GetUptime(m.startTime) |
|
|
|
m.health.Bridge.GetActiveReaders(k) |
|
|
|
m.health.Bridge.GetActiveWriters(k) |
|
|
|
m.health.Bridge.GetActiveBeacons(m) |
|
|
|
return m.health.Bridge.Marshal() |
|
|
|
} |
|
|
|
|
|
|
|
@@ -179,6 +185,12 @@ func (m *AppState) CleanLookup() { |
|
|
|
m.beaconsLookup.Lock.Unlock() |
|
|
|
} |
|
|
|
|
|
|
|
func (m *AppState) GetBeaconLookup() map[string]string { |
|
|
|
m.beaconsLookup.Lock.RLock() |
|
|
|
defer m.beaconsLookup.Lock.RUnlock() |
|
|
|
return m.beaconsLookup.Lookup |
|
|
|
} |
|
|
|
|
|
|
|
// BeaconExists checks if a beacon exists in the lookup |
|
|
|
func (m *AppState) BeaconExists(id string) (string, bool) { |
|
|
|
m.beaconsLookup.Lock.RLock() |
|
|
|
|