|
@@ -399,12 +399,12 @@ collect_status(Bridges) ->
|
|
|
[maps:with([node, status], B) || B <- Bridges].
|
|
[maps:with([node, status], B) || B <- Bridges].
|
|
|
|
|
|
|
|
aggregate_status(AllStatus) ->
|
|
aggregate_status(AllStatus) ->
|
|
|
- AllConnected = lists:all(fun (#{status := connected}) -> true;
|
|
|
|
|
- (_) -> false
|
|
|
|
|
- end, AllStatus),
|
|
|
|
|
- case AllConnected of
|
|
|
|
|
- true -> connected;
|
|
|
|
|
- false -> disconnected
|
|
|
|
|
|
|
+ Head = fun ([A | _]) -> A end,
|
|
|
|
|
+ HeadVal = maps:get(status, Head(AllStatus), connecting),
|
|
|
|
|
+ AllRes = lists:all(fun (#{status := Val}) -> Val == HeadVal end, AllStatus),
|
|
|
|
|
+ case AllRes of
|
|
|
|
|
+ true -> HeadVal;
|
|
|
|
|
+ false -> inconsistent
|
|
|
end.
|
|
end.
|
|
|
|
|
|
|
|
collect_metrics(Bridges) ->
|
|
collect_metrics(Bridges) ->
|
|
@@ -420,12 +420,11 @@ aggregate_metrics(AllMetrics) ->
|
|
|
|
|
|
|
|
format_resp(#{type := Type, name := BridgeName, raw_config := RawConf,
|
|
format_resp(#{type := Type, name := BridgeName, raw_config := RawConf,
|
|
|
resource_data := #{status := Status, metrics := Metrics}}) ->
|
|
resource_data := #{status := Status, metrics := Metrics}}) ->
|
|
|
- IsConnected = fun(connected) -> connected; (_) -> disconnected end,
|
|
|
|
|
RawConf#{
|
|
RawConf#{
|
|
|
type => Type,
|
|
type => Type,
|
|
|
name => maps:get(<<"name">>, RawConf, BridgeName),
|
|
name => maps:get(<<"name">>, RawConf, BridgeName),
|
|
|
node => node(),
|
|
node => node(),
|
|
|
- status => IsConnected(Status),
|
|
|
|
|
|
|
+ status => Status,
|
|
|
metrics => format_metrics(Metrics)
|
|
metrics => format_metrics(Metrics)
|
|
|
}.
|
|
}.
|
|
|
|
|
|