From fca69ebecd5f17e5857225a1bab6434e8b391161 Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Tue, 26 Feb 2013 18:04:45 +0000 Subject: Remove concept of strictness, thus renaming list_strict/1 to list_component/1 and removing list_strict/2 altogether, plus a few bits of therefore dead code. --- src/rabbit_runtime_parameters.erl | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/src/rabbit_runtime_parameters.erl b/src/rabbit_runtime_parameters.erl index b1100b65..05520170 100644 --- a/src/rabbit_runtime_parameters.erl +++ b/src/rabbit_runtime_parameters.erl @@ -19,7 +19,7 @@ -include("rabbit.hrl"). -export([parse_set/4, set/4, set_any/4, clear/3, clear_any/3, list/0, list/1, - list_strict/1, list/2, list_strict/2, list_formatted/1, lookup/3, + list_component/1, list/2, list_formatted/1, lookup/3, value/3, value/4, info_keys/0]). %%---------------------------------------------------------------------------- @@ -40,12 +40,9 @@ -> ok_or_error_string()). -spec(list/0 :: () -> [rabbit_types:infos()]). -spec(list/1 :: (rabbit_types:vhost() | '_') -> [rabbit_types:infos()]). --spec(list_strict/1 :: (binary() | '_') - -> [rabbit_types:infos()] | 'not_found'). +-spec(list_component/1 :: (binary()) -> [rabbit_types:infos()]). -spec(list/2 :: (rabbit_types:vhost() | '_', binary() | '_') -> [rabbit_types:infos()]). --spec(list_strict/2 :: (rabbit_types:vhost() | '_', binary() | '_') - -> [rabbit_types:infos()] | 'not_found'). -spec(list_formatted/1 :: (rabbit_types:vhost()) -> [rabbit_types:infos()]). -spec(lookup/3 :: (rabbit_types:vhost(), binary(), binary()) -> rabbit_types:infos() | 'not_found'). @@ -139,21 +136,14 @@ list() -> [p(P) || #runtime_parameters{ key = {_VHost, Comp, _Name}} = P <- rabbit_misc:dirty_read_all(?TABLE), Comp /= <<"policy">>]. -list(VHost) -> list(VHost, '_', []). -list_strict(Component) -> list('_', Component, not_found). -list(VHost, Component) -> list(VHost, Component, []). -list_strict(VHost, Component) -> list(VHost, Component, not_found). - -list(VHost, Component, Default) -> - case component_good(Component) of - true -> Match = #runtime_parameters{key = {VHost, Component, '_'}, - _ = '_'}, - [p(P) || #runtime_parameters{ key = {_VHost, Comp, _Name}} = P <- - mnesia:dirty_match_object(?TABLE, Match), - Comp =/= <<"policy">> orelse - Component =:= <<"policy">>]; - _ -> Default - end. +list(VHost) -> list(VHost, '_'). +list_component(Component) -> list('_', Component). + +list(VHost, Component) -> + Match = #runtime_parameters{key = {VHost, Component, '_'}, _ = '_'}, + [p(P) || #runtime_parameters{key = {_VHost, Comp, _Name}} = P <- + mnesia:dirty_match_object(?TABLE, Match), + Comp =/= <<"policy">> orelse Component =:= <<"policy">>]. list_formatted(VHost) -> [pset(value, format(pget(value, P)), P) || P <- list(VHost)]. @@ -208,12 +198,6 @@ info_keys() -> [component, name, value]. %%--------------------------------------------------------------------------- -component_good('_') -> true; -component_good(Component) -> case lookup_component(Component) of - {ok, _} -> true; - _ -> false - end. - lookup_component(Component) -> case rabbit_registry:lookup_module( runtime_parameter, list_to_atom(binary_to_list(Component))) of -- cgit v1.2.1