-
Notifications
You must be signed in to change notification settings - Fork 210
/
SubscriptionHealth.js
29 lines (26 loc) · 1.3 KB
/
SubscriptionHealth.js
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
var health = angular.module('hermes.subscription.health', []);
health.factory('SubscriptionHealth', ['DiscoveryService', '$resource',
function (discovery, $resource) {
var health = $resource(discovery.resolve('/topics/:topicName/subscriptions/:subscriptionName/health'));
return {
health: function (topicName, subscriptionName) {
return health.get({topicName: topicName, subscriptionName: subscriptionName})
.$promise.then(function (health) {
var problemOccurs = function (problemCode) {
return _.some(health.problems, {code: problemCode})
};
return {
status: health.status,
problems: {
lagging: problemOccurs('LAGGING'),
malfunctioning: problemOccurs('MALFUNCTIONING'),
receivingMalformedMessages: problemOccurs('RECEIVING_MALFORMED_MESSAGES'),
timingOut: problemOccurs('TIMING_OUT'),
unreachable: problemOccurs('UNREACHABLE')
}
};
});
}
};
}
]);