4242
4343-export ([register /0 ]).
4444-export ([invalidate /0 , recover /0 ]).
45- -export ([name /1 , name_op /1 , effective_definition /1 , get /2 , get_arg /3 , set /1 ]).
45+ -export ([name /1 , name_op /1 , effective_definition /1 , merge_operator_definitions / 2 , get /2 , get_arg /3 , set /1 ]).
4646-export ([validate /5 , notify /5 , notify_clear /4 ]).
4747-export ([parse_set /7 , set /7 , delete /3 , lookup /2 , list /0 , list /1 ,
4848 list_formatted /1 , list_formatted /3 , info_keys /0 ]).
@@ -69,23 +69,23 @@ name0(undefined) -> none;
6969name0 (Policy ) -> pget (name , Policy ).
7070
7171effective_definition (# amqqueue {policy = Policy , operator_policy = OpPolicy }) ->
72- effective_definition0 (Policy , OpPolicy );
72+ merge_operator_definitions (Policy , OpPolicy );
7373effective_definition (# exchange {policy = Policy , operator_policy = OpPolicy }) ->
74- effective_definition0 (Policy , OpPolicy ).
75-
76- effective_definition0 (undefined , undefined ) -> undefined ;
77- effective_definition0 (Policy , undefined ) -> pget (definition , Policy );
78- effective_definition0 (undefined , OpPolicy ) -> pget (definition , OpPolicy );
79- effective_definition0 (Policy , OpPolicy ) ->
80- OpDefinition = pget (definition , OpPolicy , []),
81- Definition = pget (definition , Policy , []),
82- { Keys , _ } = lists : unzip (Definition ),
83- { OpKeys , _ } = lists : unzip (OpDefinition ),
74+ merge_operator_definitions (Policy , OpPolicy ).
75+
76+ merge_operator_definitions (undefined , undefined ) -> undefined ;
77+ merge_operator_definitions (Policy , undefined ) -> pget (definition , Policy );
78+ merge_operator_definitions (undefined , OpPolicy ) -> pget (definition , OpPolicy );
79+ merge_operator_definitions (Policy , OpPolicy ) ->
80+ OpDefinition = rabbit_data_coercion : to_map ( pget (definition , OpPolicy , []) ),
81+ Definition = rabbit_data_coercion : to_map ( pget (definition , Policy , []) ),
82+ Keys = maps : keys (Definition ),
83+ OpKeys = maps : keys (OpDefinition ),
8484 lists :map (fun (Key ) ->
85- case {pget (Key , Definition ), pget (Key , OpDefinition )} of
86- {Val , undefined } -> {Key , Val };
87- {undefined , Val } -> {Key , Val };
88- {Val , OpVal } -> {Key , merge_policy_value (Key , Val , OpVal )}
85+ case {maps : get (Key , Definition , undefined ), maps : get (Key , OpDefinition , undefined )} of
86+ {Val , undefined } -> {Key , Val };
87+ {undefined , OpVal } -> {Key , OpVal };
88+ {Val , OpVal } -> {Key , merge_policy_value (Key , Val , OpVal )}
8989 end
9090 end ,
9191 lists :umerge (Keys , OpKeys )).
@@ -128,7 +128,7 @@ get0(Name, Policy, OpPolicy) ->
128128merge_policy_value (Name , PolicyVal , OpVal ) ->
129129 case policy_merge_strategy (Name ) of
130130 {ok , Module } -> Module :merge_policy_value (Name , PolicyVal , OpVal );
131- {error , not_found } -> PolicyVal
131+ {error , not_found } -> rabbit_policies : merge_policy_value ( Name , PolicyVal , OpVal )
132132 end .
133133
134134policy_merge_strategy (Name ) ->
0 commit comments