diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2011-06-02 15:00:44 +0100 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2011-06-02 15:00:44 +0100 |
| commit | 3ccb10b6af5d8393efc15eac07f6d0f6f2ed8f62 (patch) | |
| tree | 534c4daaea9fd2e3fca8d0c11902de1abdd38037 | |
| parent | c4ddb406dca4b73fe58397aeb54a2800fbcf2959 (diff) | |
| download | rabbitmq-server-git-3ccb10b6af5d8393efc15eac07f6d0f6f2ed8f62.tar.gz | |
Move pget from federation / mgmt to misc.
| -rw-r--r-- | src/rabbit_misc.erl | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index cebb888fca..b6b97f6dec 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -56,6 +56,7 @@ -export([const_ok/0, const/1]). -export([ntoa/1, ntoab/1]). -export([is_process_alive/1]). +-export([pget/2, pget/3, pget_or_die/2]). %%---------------------------------------------------------------------------- @@ -201,6 +202,9 @@ -spec(ntoa/1 :: (inet:ip_address()) -> string()). -spec(ntoab/1 :: (inet:ip_address()) -> string()). -spec(is_process_alive/1 :: (pid()) -> boolean()). +-spec(pget/2 :: (term(), [term()]) -> term()). +-spec(pget/3 :: (term(), [term()], term()) -> term()). +-spec(pget_or_die/2 :: (term(), [term()]) -> term() | no_return()). -endif. @@ -906,3 +910,12 @@ is_process_alive(Pid) -> true -> true; _ -> false end. + +pget(K, P) -> proplists:get_value(K, P). +pget(K, P, D) -> proplists:get_value(K, P, D). + +pget_or_die(K, P) -> + case proplists:get_value(K, P) of + undefined -> exit({error, key_missing, K}); + V -> V + end. |
