./ct_report/coverage/mongoose_graphql_cets_admin_query.COVER.html

1 -module(mongoose_graphql_cets_admin_query).
2 -behaviour(mongoose_graphql).
3 -include("mongoose_logger.hrl").
4
5 -export([execute/4]).
6
7 -import(mongoose_graphql_helper, [make_error/2]).
8
9 -ignore_xref([execute/4]).
10
11 -include("../mongoose_graphql_types.hrl").
12
13 execute(Ctx, cets, <<"systemInfo">>, _) ->
14 24 try cets_status:status(mongoose_cets_discovery) of
15 #{available_nodes := AvNodes,
16 unavailable_nodes := UnNodes,
17 joined_nodes := Joined,
18 discovered_nodes := DiscoNodes,
19 discovery_works := DiscoveryWorks,
20 remote_nodes_without_disco := NoDisco,
21 remote_nodes_with_unknown_tables := UnkNodes,
22 remote_unknown_tables := UnkTabs,
23 remote_nodes_with_missing_tables := MissNodes,
24 remote_missing_tables := MissTabs,
25 conflict_nodes := ConNodes,
26 conflict_tables := ConTabs} ->
27 24 {ok, #{<<"availableNodes">> => format_nodes(AvNodes),
28 <<"unavailableNodes">> => format_nodes(UnNodes),
29 <<"joinedNodes">> => format_nodes(Joined),
30 <<"discoveredNodes">> => format_nodes(DiscoNodes),
31 <<"remoteNodesWithoutDisco">> => format_nodes(NoDisco),
32 <<"remoteNodesWithUnknownTables">> => format_nodes(UnkNodes),
33 <<"remoteUnknownTables">> => format_tables(UnkTabs),
34 <<"remoteNodesWithMissingTables">> => format_nodes(MissNodes),
35 <<"remoteMissingTables">> => format_tables(MissTabs),
36 <<"conflictNodes">> => format_nodes(ConNodes),
37 <<"conflictTables">> => format_tables(ConTabs),
38 <<"discoveryWorks">> => DiscoveryWorks}}
39 catch Class:Reason:Stacktrace ->
40
:-(
?LOG_ERROR(#{what => cets_system_info_failed, class => Class,
41
:-(
reason => Reason, stacktrace => Stacktrace}),
42
:-(
make_error({Reason, <<"Failed to get CETS system info">>}, Ctx)
43 end;
44 execute(Ctx, cets, <<"tableInfo">>, _) ->
45 2 try cets_discovery:info(mongoose_cets_discovery) of
46 Tables ->
47 2 {ok, lists:map(fun process_result/1, Tables)}
48 catch _Class:Reason ->
49
:-(
make_error({Reason, <<"Failed to get CETS tables info">>}, Ctx)
50 end.
51
52 process_result(#{memory := Memory, size := Size, nodes := Nodes, table := Tab}) ->
53 16 {ok, #{<<"memory">> => Memory, <<"size">> => Size,
54 <<"nodes">> => format_nodes(Nodes), <<"tableName">> => Tab}}.
55
56 format_nodes(Nodes) ->
57 208 [{ok, Node} || Node <- Nodes].
58
59 format_tables(Nodes) ->
60 72 [{ok, Node} || Node <- Nodes].
Line Hits Source