diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2013-09-03 11:49:13 +0100 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2013-09-03 11:49:13 +0100 |
| commit | 7da554f11615a5ec18a21659bdae08e406cc952d (patch) | |
| tree | 68615924e87eb7639ca3b3050e7e4cd4ce4aa63e /src | |
| parent | a0c79f5d1f5941c9cb855f90180b071b23f0ef90 (diff) | |
| download | rabbitmq-server-git-7da554f11615a5ec18a21659bdae08e406cc952d.tar.gz | |
Configure AE by policy.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_exchange.erl | 9 | ||||
| -rw-r--r-- | src/rabbit_policies.erl | 40 |
2 files changed, 45 insertions, 4 deletions
diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index 49952a4d70..bdb0f5db48 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -347,11 +347,12 @@ route1(Delivery, Decorators, lists:foldl(fun process_route/2, {WorkList, SeenXs, QNames}, AlternateDests ++ DecorateDests ++ ExchangeDests)). -process_alternate(#exchange{arguments = []}, _Results) -> %% optimisation - []; -process_alternate(#exchange{name = XName, arguments = Args}, []) -> +process_alternate(X = #exchange{name = XName, arguments = Args}, []) -> case rabbit_misc:r_arg(XName, exchange, Args, <<"alternate-exchange">>) of - undefined -> []; + undefined -> case rabbit_policy:get(<<"alternate-exchange">>, X) of + {ok, AName} -> [rabbit_misc:r(XName, exchange, AName)]; + {error, _} -> [] + end; AName -> [AName] end; process_alternate(_X, _Results) -> diff --git a/src/rabbit_policies.erl b/src/rabbit_policies.erl new file mode 100644 index 0000000000..20f461bcb2 --- /dev/null +++ b/src/rabbit_policies.erl @@ -0,0 +1,40 @@ +%% 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 GoPivotal, Inc. +%% Copyright (c) 2007-2013 GoPivotal, Inc. All rights reserved. +%% + +-module(rabbit_policies). +-behaviour(rabbit_policy_validator). + +-include("rabbit.hrl"). + +-export([register/0, validate_policy/1]). + +-rabbit_boot_step({?MODULE, + [{description, "internal policies"}, + {mfa, {rabbit_policies, register, []}}, + {requires, rabbit_registry}, + {enables, recovery}]}). + +register() -> + [rabbit_registry:register(Class, Name, ?MODULE) || + {Class, Name} <- [{policy_validator, <<"alternate-exchange">>}]], + ok. + +validate_policy([{<<"alternate-exchange">>, Value}]) + when is_binary(Value) -> + ok; +validate_policy([{<<"alternate-exchange">>, Value}]) -> + {error, "~p is not a valid alternate exchange name", [Value]}. + |
