summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-03-31 15:25:02 +0100
committerSimon MacMullen <simon@rabbitmq.com>2014-03-31 15:25:02 +0100
commit5f64e60c02d50fc4c094356f2df480f0dea68422 (patch)
tree6efa352dff0decb60abb69bd60cdbdaea4a98e13
parent5aae9351773a03c2d4c1e15adaac60cf34ace58f (diff)
downloadrabbitmq-server-5f64e60c02d50fc4c094356f2df480f0dea68422.tar.gz
Events for policies and parameters.
-rw-r--r--src/rabbit_policy.erl6
-rw-r--r--src/rabbit_runtime_parameters.erl17
2 files changed, 19 insertions, 4 deletions
diff --git a/src/rabbit_policy.erl b/src/rabbit_policy.erl
index 06bfaf17..632f2c66 100644
--- a/src/rabbit_policy.erl
+++ b/src/rabbit_policy.erl
@@ -200,10 +200,12 @@ validate(_VHost, <<"policy">>, Name, Term) ->
rabbit_parameter_validation:proplist(
Name, policy_validation(), Term).
-notify(VHost, <<"policy">>, _Name, _Term) ->
+notify(VHost, <<"policy">>, Name, Term) ->
+ rabbit_event:notify(policy_set, [{name, Name} | Term]),
update_policies(VHost).
-notify_clear(VHost, <<"policy">>, _Name) ->
+notify_clear(VHost, <<"policy">>, Name) ->
+ rabbit_event:notify(policy_cleared, [{name, Name}]),
update_policies(VHost).
%%----------------------------------------------------------------------------
diff --git a/src/rabbit_runtime_parameters.erl b/src/rabbit_runtime_parameters.erl
index 877714a1..ba6b9538 100644
--- a/src/rabbit_runtime_parameters.erl
+++ b/src/rabbit_runtime_parameters.erl
@@ -99,7 +99,11 @@ set_any0(VHost, Component, Name, Term) ->
ok ->
case mnesia_update(VHost, Component, Name, Term) of
{old, Term} -> ok;
- _ -> Mod:notify(VHost, Component, Name, Term)
+ _ -> event_notify(
+ parameter_set, VHost, Component,
+ [{name, Name},
+ {value, Term}]),
+ Mod:notify(VHost, Component, Name, Term)
end,
ok;
E ->
@@ -136,7 +140,10 @@ clear_any(VHost, Component, Name) ->
not_found -> {error_string, "Parameter does not exist"};
_ -> mnesia_clear(VHost, Component, Name),
case lookup_component(Component) of
- {ok, Mod} -> Mod:notify_clear(VHost, Component, Name);
+ {ok, Mod} -> event_notify(
+ parameter_cleared, VHost, Component,
+ [{name, Name}]),
+ Mod:notify_clear(VHost, Component, Name);
_ -> ok
end
end.
@@ -147,6 +154,12 @@ mnesia_clear(VHost, Component, Name) ->
end,
ok = rabbit_misc:execute_mnesia_transaction(rabbit_vhost:with(VHost, F)).
+event_notify(_Event, _VHost, <<"policy">>, _Props) ->
+ ok;
+event_notify(Event, VHost, Component, Props) ->
+ rabbit_event:notify(Event, [{vhost, VHost},
+ {component, Component} | Props]).
+
list() ->
[p(P) || #runtime_parameters{ key = {_VHost, Comp, _Name}} = P <-
rabbit_misc:dirty_read_all(?TABLE), Comp /= <<"policy">>].