refactor: improve bookkeeping api
This commit is contained in:
parent
6dbf015c93
commit
6da71200f3
|
@ -83,9 +83,7 @@ handle_tally_routes() ->
|
|||
ok.
|
||||
|
||||
tally_routes([ClusterName | ClusterNames]) ->
|
||||
Tab = emqx_cluster_link_extrouter:extroute_tab(),
|
||||
Pat = emqx_cluster_link_extrouter:cluster_routes_ms(ClusterName),
|
||||
NumRoutes = ets:select_count(Tab, Pat),
|
||||
NumRoutes = emqx_cluster_link_extrouter:count(ClusterName),
|
||||
emqx_cluster_link_metrics:routes_set(ClusterName, NumRoutes),
|
||||
tally_routes(ClusterNames);
|
||||
tally_routes([]) ->
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
]).
|
||||
|
||||
%% Internal export for bookkeeping
|
||||
-export([cluster_routes_ms/1, extroute_tab/0]).
|
||||
-export([count/1]).
|
||||
|
||||
%% Strictly monotonically increasing integer.
|
||||
-type smint() :: integer().
|
||||
|
@ -151,16 +151,14 @@ make_extroute_rec_pat(Entry) ->
|
|||
).
|
||||
|
||||
%% Internal exports for bookkeeping
|
||||
cluster_routes_ms(ClusterName) ->
|
||||
count(ClusterName) ->
|
||||
TopicPat = '_',
|
||||
RouteIDPat = '_',
|
||||
Pat = make_extroute_rec_pat(
|
||||
emqx_trie_search:make_pat(TopicPat, ?ROUTE_ID(ClusterName, RouteIDPat))
|
||||
),
|
||||
[{Pat, [], [true]}].
|
||||
|
||||
extroute_tab() ->
|
||||
?EXTROUTE_TAB.
|
||||
MS = [{Pat, [], [true]}],
|
||||
ets:select_count(?EXTROUTE_TAB, MS).
|
||||
|
||||
%%
|
||||
|
||||
|
|
Loading…
Reference in New Issue