diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2012-03-22 15:21:43 +0000 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2012-03-22 15:21:43 +0000 |
| commit | ae1a7e4f751fe1b023f50453ea15eb55576609cb (patch) | |
| tree | 92f704f81f1864a28170560bd8bd377e65413e87 | |
| parent | 753c485a48d8f8a6ac3ebf391ad025f52750e7e5 (diff) | |
| download | rabbitmq-server-git-ae1a7e4f751fe1b023f50453ea15eb55576609cb.tar.gz | |
Allow string keys, format the results for listing.
| -rw-r--r-- | src/rabbit_cluster_config.erl | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/rabbit_cluster_config.erl b/src/rabbit_cluster_config.erl index 50680ffe72..0d1dbf35dc 100644 --- a/src/rabbit_cluster_config.erl +++ b/src/rabbit_cluster_config.erl @@ -46,8 +46,8 @@ list() -> All = rabbit_misc:dirty_read_all(?TABLE), [[{app_name, AppName}, {key, Key}, - {value, Value}] || #cluster_config{key = {AppName, Key}, - value = Value} <- All]. + {value, format(Value)}] || #cluster_config{key = {AppName, Key}, + value = Value} <- All]. lookup(AppName, Key, Default) -> case mnesia:dirty_read(?TABLE, {AppName, Key}) of @@ -94,6 +94,9 @@ parse(Src) -> format_parse_error({_Line, Mod, Err}) -> lists:flatten(Mod:format_error(Err)). +format(Term) -> + list_to_binary(rabbit_misc:format("~p", [Term])). + %%--------------------------------------------------------------------------- %% We will want to be able to biject these to JSON. So we have some @@ -110,5 +113,7 @@ validate(B) when is_binary(B) -> ok. validate_proplist([]) -> ok; validate_proplist([{K, V} | Rest]) when is_atom(K) -> validate(V), validate_proplist(Rest); -validate_proplist([{K, _V} | _Rest]) -> exit({non_atom_key, K}); +validate_proplist([{K, V} | Rest]) when is_list(K) -> validate(V), + validate_proplist(Rest); +validate_proplist([{K, _V} | _Rest]) -> exit({bad_key, K}); validate_proplist([H | _Rest]) -> exit({not_two_tuple, H}). |
