diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2013-05-09 12:42:41 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2013-05-09 12:42:41 +0100 |
commit | e998a4c8ce397ae36d9e26780d9b7b78faed5d75 (patch) | |
tree | 38ebca738d0b3aac03a4be4b791a0fc059b75277 | |
parent | ed423cfac2de5210d6e68085e6e15acf2db32476 (diff) | |
download | rabbitmq-server-e998a4c8ce397ae36d9e26780d9b7b78faed5d75.tar.gz |
Refactor.
-rw-r--r-- | src/rabbit_runtime_parameters.erl | 8 | ||||
-rw-r--r-- | src/rabbit_vhost.erl | 10 |
2 files changed, 10 insertions, 8 deletions
diff --git a/src/rabbit_runtime_parameters.erl b/src/rabbit_runtime_parameters.erl index fd0c1915..e1c962b4 100644 --- a/src/rabbit_runtime_parameters.erl +++ b/src/rabbit_runtime_parameters.erl @@ -140,7 +140,7 @@ list(VHost) -> list(VHost, '_'). list_component(Component) -> list('_', Component). list(VHost, Component) -> - assert_vhost(VHost), + rabbit_vhost:assert(VHost), Match = #runtime_parameters{key = {VHost, Component, '_'}, _ = '_'}, [p(P) || #runtime_parameters{key = {_VHost, Comp, _Name}} = P <- mnesia:dirty_match_object(?TABLE, Match), @@ -149,12 +149,6 @@ list(VHost, Component) -> list_formatted(VHost) -> [pset(value, format(pget(value, P)), P) || P <- list(VHost)]. -assert_vhost('_') -> ok; -assert_vhost(VHost) -> case rabbit_vhost:exists(VHost) of - true -> ok; - false -> throw({error, {no_such_vhost, VHost}}) - end. - lookup(VHost, Component, Name) -> case lookup0(VHost, Component, Name, rabbit_misc:const(not_found)) of not_found -> not_found; diff --git a/src/rabbit_vhost.erl b/src/rabbit_vhost.erl index 2858cf58..b5d8b5e4 100644 --- a/src/rabbit_vhost.erl +++ b/src/rabbit_vhost.erl @@ -20,7 +20,7 @@ %%---------------------------------------------------------------------------- --export([add/1, delete/1, exists/1, list/0, with/2]). +-export([add/1, delete/1, exists/1, list/0, with/2, assert/1]). -export([info/1, info/2, info_all/0, info_all/1]). -ifdef(use_specs). @@ -30,6 +30,7 @@ -spec(exists/1 :: (rabbit_types:vhost()) -> boolean()). -spec(list/0 :: () -> [rabbit_types:vhost()]). -spec(with/2 :: (rabbit_types:vhost(), rabbit_misc:thunk(A)) -> A). +-spec(assert/1 :: (rabbit_types:vhost()) -> 'ok'). -spec(info/1 :: (rabbit_types:vhost()) -> rabbit_types:infos()). -spec(info/2 :: (rabbit_types:vhost(), rabbit_types:info_keys()) @@ -120,6 +121,13 @@ with(VHostPath, Thunk) -> end end. +%% Like with/2 but outside an Mnesia tx +assert('_') -> ok; +assert(VHostPath) -> case rabbit_vhost:exists(VHostPath) of + true -> ok; + false -> throw({error, {no_such_vhost, VHostPath}}) + end. + %%---------------------------------------------------------------------------- infos(Items, X) -> [{Item, i(Item, X)} || Item <- Items]. |