Merge pull request #10260 from thalesmg/minor-refactor-basic-usage-rule-rv50
refactor(rule_engine): use more helper functions
This commit is contained in:
commit
5089449203
|
@ -319,14 +319,8 @@ get_basic_usage_info() ->
|
||||||
ReferencedBridges =
|
ReferencedBridges =
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun(#{actions := Actions, from := Froms}, Acc) ->
|
fun(#{actions := Actions, from := Froms}, Acc) ->
|
||||||
BridgeIDs0 =
|
BridgeIDs0 = get_referenced_hookpoints(Froms),
|
||||||
[
|
BridgeIDs1 = get_egress_bridges(Actions),
|
||||||
BridgeID
|
|
||||||
|| From <- Froms,
|
|
||||||
{ok, BridgeID} <-
|
|
||||||
[emqx_bridge_resource:bridge_hookpoint_to_bridge_id(From)]
|
|
||||||
],
|
|
||||||
BridgeIDs1 = lists:filter(fun is_binary/1, Actions),
|
|
||||||
tally_referenced_bridges(BridgeIDs0 ++ BridgeIDs1, Acc)
|
tally_referenced_bridges(BridgeIDs0 ++ BridgeIDs1, Acc)
|
||||||
end,
|
end,
|
||||||
#{},
|
#{},
|
||||||
|
@ -490,10 +484,8 @@ forwards_to_bridge(Actions, BridgeId) ->
|
||||||
lists:any(fun(A) -> A =:= BridgeId end, Actions).
|
lists:any(fun(A) -> A =:= BridgeId end, Actions).
|
||||||
|
|
||||||
references_ingress_bridge(Froms, BridgeId) ->
|
references_ingress_bridge(Froms, BridgeId) ->
|
||||||
lists:any(
|
lists:member(
|
||||||
fun(ReferenceBridgeId) ->
|
BridgeId,
|
||||||
BridgeId =:= ReferenceBridgeId
|
|
||||||
end,
|
|
||||||
[
|
[
|
||||||
RefBridgeId
|
RefBridgeId
|
||||||
|| From <- Froms,
|
|| From <- Froms,
|
||||||
|
@ -501,3 +493,14 @@ references_ingress_bridge(Froms, BridgeId) ->
|
||||||
[emqx_bridge_resource:bridge_hookpoint_to_bridge_id(From)]
|
[emqx_bridge_resource:bridge_hookpoint_to_bridge_id(From)]
|
||||||
]
|
]
|
||||||
).
|
).
|
||||||
|
|
||||||
|
get_referenced_hookpoints(Froms) ->
|
||||||
|
[
|
||||||
|
BridgeID
|
||||||
|
|| From <- Froms,
|
||||||
|
{ok, BridgeID} <-
|
||||||
|
[emqx_bridge_resource:bridge_hookpoint_to_bridge_id(From)]
|
||||||
|
].
|
||||||
|
|
||||||
|
get_egress_bridges(Actions) ->
|
||||||
|
lists:filter(fun is_binary/1, Actions).
|
||||||
|
|
Loading…
Reference in New Issue