summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_exchange.erl12
-rw-r--r--src/rabbit_exchange_decorator.erl46
-rw-r--r--src/rabbit_registry.erl7
3 files changed, 60 insertions, 5 deletions
diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl
index 83e28c44a8..853c35498f 100644
--- a/src/rabbit_exchange.erl
+++ b/src/rabbit_exchange.erl
@@ -101,7 +101,15 @@ recover() ->
[XName || #exchange{name = XName} <- Xs].
callback(#exchange{type = XType}, Fun, Args) ->
- apply(type_to_module(XType), Fun, Args).
+ callback(type_to_module(XType), Fun, Args);
+
+callback(Module, Fun, Args) ->
+ %% TODO cache this?
+ %% TODO what about serialising events?
+ %% TODO what about sharing the scratch space?
+ Decorators = rabbit_registry:lookup_all(exchange_decorator),
+ [ok = apply(M, Fun, Args) || {_, M} <- Decorators],
+ apply(Module, Fun, Args).
declare(XName, Type, Durable, AutoDelete, Internal, Args) ->
X = #exchange{name = XName,
@@ -129,7 +137,7 @@ declare(XName, Type, Durable, AutoDelete, Internal, Args) ->
end
end,
fun ({new, Exchange}, Tx) ->
- ok = XT:create(map_create_tx(Tx), Exchange),
+ ok = callback(XT, create, [map_create_tx(Tx), Exchange]),
rabbit_event:notify_if(not Tx, exchange_created, info(Exchange)),
Exchange;
({existing, Exchange}, _Tx) ->
diff --git a/src/rabbit_exchange_decorator.erl b/src/rabbit_exchange_decorator.erl
new file mode 100644
index 0000000000..362ec30964
--- /dev/null
+++ b/src/rabbit_exchange_decorator.erl
@@ -0,0 +1,46 @@
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (the "License"); you may not use this file except in
+%% compliance with the License. You may obtain a copy of the License
+%% at http://www.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and
+%% limitations under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developer of the Original Code is VMware, Inc.
+%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
+%%
+
+-module(rabbit_exchange_decorator).
+
+-export([behaviour_info/1]).
+
+behaviour_info(callbacks) ->
+ [
+ {description, 0},
+
+ %% Should Rabbit ensure that all binding events that are
+ %% delivered to an individual exchange can be serialised? (they
+ %% might still be delivered out of order, but there'll be a
+ %% serial number).
+ {serialise_events, 0},
+
+ {route, 2},
+
+ %% called after declaration and recovery
+ {create, 2},
+
+ %% called after exchange (auto)deletion.
+ {delete, 3},
+
+ %% called after a binding has been added or recovered
+ {add_binding, 3},
+
+ %% called after bindings have been deleted.
+ {remove_bindings, 3}
+ ];
+behaviour_info(_Other) ->
+ undefined.
diff --git a/src/rabbit_registry.erl b/src/rabbit_registry.erl
index 46c93503d2..33e3135a53 100644
--- a/src/rabbit_registry.erl
+++ b/src/rabbit_registry.erl
@@ -95,9 +95,10 @@ sanity_check_module(ClassModule, Module) ->
true -> ok
end.
-class_module(exchange) -> rabbit_exchange_type;
-class_module(auth_mechanism) -> rabbit_auth_mechanism;
-class_module(runtime_parameter) -> rabbit_runtime_parameter.
+class_module(exchange) -> rabbit_exchange_type;
+class_module(auth_mechanism) -> rabbit_auth_mechanism;
+class_module(runtime_parameter) -> rabbit_runtime_parameter;
+class_module(exchange_decorator) -> rabbit_exchange_decorator.
%%---------------------------------------------------------------------------