diff options
| author | Ayanda Dube <ayanda.dube@erlang-solutions.com> | 2015-07-15 11:12:12 +0100 |
|---|---|---|
| committer | Ayanda Dube <ayanda.dube@erlang-solutions.com> | 2015-07-15 11:12:12 +0100 |
| commit | b0c7deec130e94f93bee90d92f2d3a6c1be71d77 (patch) | |
| tree | 3d5eb0029767e8d4ca9296c3b57a61557d295dfc /src | |
| parent | 6b3056448154869c82b459682f7df2e2f4163f9a (diff) | |
| download | rabbitmq-server-git-b0c7deec130e94f93bee90d92f2d3a6c1be71d77.tar.gz | |
Moves callback execution to one place
Renames functions
References #121
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_queue_master_location_misc.erl | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/src/rabbit_queue_master_location_misc.erl b/src/rabbit_queue_master_location_misc.erl index 03cef8bc03..c720dc4654 100644 --- a/src/rabbit_queue_master_location_misc.erl +++ b/src/rabbit_queue_master_location_misc.erl @@ -21,9 +21,9 @@ -export([lookup_master/2, lookup_queue/2, get_location/1, - get_location_by_config/1, - get_location_by_args/1, - get_location_by_policy/1, + get_location_mod_by_config/1, + get_location_mod_by_args/1, + get_location_mod_by_policy/1, all_nodes/0]). lookup_master(QueueNameBin, VHostPath) when is_binary(QueueNameBin), @@ -44,45 +44,50 @@ lookup_queue(QueueNameBin, VHostPath) when is_binary(QueueNameBin), end. get_location(Queue=#amqqueue{})-> - case get_location_by_args(Queue) of - _Err1={error, _} -> - case get_location_by_policy(Queue) of - _Err2={error, _} -> - case get_location_by_config(Queue) of - Err3={error, _} -> Err3; - Reply={ok, _Node} -> Reply + Reply1 = case get_location_mod_by_args(Queue) of + _Err1={error, _} -> + case get_location_mod_by_policy(Queue) of + _Err2={error, _} -> + case get_location_mod_by_config(Queue) of + Err3={error, _} -> Err3; + Reply0={ok, _Module} -> Reply0 + end; + Reply0={ok, _Module} -> Reply0 end; - Reply={ok, _Node} -> Reply - end; - Reply={ok, _Node} -> Reply + Reply0={ok, _Module} -> Reply0 + end, + + case Reply1 of + {ok, CB} -> CB:queue_master_location(Queue); + Error -> Error end. -get_location_by_args(Queue=#amqqueue{arguments=Args}) -> +get_location_mod_by_args(#amqqueue{arguments=Args}) -> case proplists:lookup(<<"queue-master-location">> , Args) of {<<"queue-master-location">> , Strategy} -> case rabbit_queue_location_validator:validate_strategy(Strategy) of - {ok, CB} -> CB:queue_master_location(Queue); - Error -> Error + Reply={ok, _CB} -> Reply; + Error -> Error end; _ -> {error, "queue-master-location undefined"} end. -get_location_by_policy(Queue=#amqqueue{}) -> +get_location_mod_by_policy(Queue=#amqqueue{}) -> case rabbit_policy:get(<<"queue-master-location">> , Queue) of undefined -> {error, "queue-master-location policy undefined"}; Strategy -> case rabbit_queue_location_validator:validate_strategy(Strategy) of - {ok, CB} -> CB:queue_master_location(Queue); + Reply={ok, _CB} -> Reply; Error -> Error end end. -get_location_by_config(Queue=#amqqueue{}) -> +get_location_mod_by_config(#amqqueue{}) -> case application:get_env(rabbit, queue_master_location) of {ok, Strategy} -> case rabbit_queue_location_validator:validate_strategy(Strategy) of - {ok, CB} -> CB:queue_master_location(Queue); - Error -> Error + Reply={ok, _CB} -> Reply; + Error -> Error end; _ -> {error, "queue-master-location undefined"} end. |
