diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2014-08-11 12:15:58 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2014-08-11 12:15:58 +0100 |
commit | 64298e9d2b3879be54b4297376c2a29d9d65175b (patch) | |
tree | be3fb40a0543294de72f07ca7601f90aadd6268e /src/rabbit_exchange_decorator.erl | |
parent | fabe3df8c2eba2b852e34ca0b4a163550e7d6c9b (diff) | |
parent | a1884877808f6c34c349e132b31db9e45de347d0 (diff) | |
download | rabbitmq-server-64298e9d2b3879be54b4297376c2a29d9d65175b.tar.gz |
stable to default
Diffstat (limited to 'src/rabbit_exchange_decorator.erl')
-rw-r--r-- | src/rabbit_exchange_decorator.erl | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/rabbit_exchange_decorator.erl b/src/rabbit_exchange_decorator.erl index 2f056b1b..900f9c32 100644 --- a/src/rabbit_exchange_decorator.erl +++ b/src/rabbit_exchange_decorator.erl @@ -18,7 +18,7 @@ -include("rabbit.hrl"). --export([select/2, set/1]). +-export([select/2, set/1, register/2, unregister/1]). %% This is like an exchange type except that: %% @@ -104,3 +104,25 @@ list() -> [M || {_, M} <- rabbit_registry:lookup_all(exchange_decorator)]. cons_if_eq(Select, Select, Item, List) -> [Item | List]; cons_if_eq(_Select, _Other, _Item, List) -> List. + +register(TypeName, ModuleName) -> + rabbit_registry:register(exchange_decorator, TypeName, ModuleName), + [maybe_recover(X) || X <- rabbit_exchange:list()], + ok. + +unregister(TypeName) -> + rabbit_registry:unregister(exchange_decorator, TypeName), + [maybe_recover(X) || X <- rabbit_exchange:list()], + ok. + +maybe_recover(X = #exchange{name = Name, + decorators = Decs}) -> + #exchange{decorators = Decs1} = set(X), + Old = lists:sort(select(all, Decs)), + New = lists:sort(select(all, Decs1)), + case New of + Old -> ok; + _ -> %% TODO create a tx here for non-federation decorators + [M:create(none, X) || M <- New -- Old], + rabbit_exchange:update_decorators(Name) + end. |