diff options
| author | Matthew Sackman <matthew@rabbitmq.com> | 2010-09-12 19:12:18 +0100 |
|---|---|---|
| committer | Matthew Sackman <matthew@rabbitmq.com> | 2010-09-12 19:12:18 +0100 |
| commit | 0473e44ebb9cb0386afda155908bdd2ce41ea27d (patch) | |
| tree | be26e092af43bf8f568c442673090c2c77156f84 /src | |
| parent | 0aff23ef73ab7f2e480d63da58031298d500ddc4 (diff) | |
| download | rabbitmq-server-git-0473e44ebb9cb0386afda155908bdd2ce41ea27d.tar.gz | |
Do the simplest thing and have additional fields to indicate the type of the binding endpoints
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_binding.erl | 14 | ||||
| -rw-r--r-- | src/rabbit_control.erl | 22 |
2 files changed, 16 insertions, 20 deletions
diff --git a/src/rabbit_binding.erl b/src/rabbit_binding.erl index eff93baff9..b12927e8ab 100644 --- a/src/rabbit_binding.erl +++ b/src/rabbit_binding.erl @@ -90,7 +90,9 @@ %%---------------------------------------------------------------------------- --define(INFO_KEYS, [source, destination, routing_key, arguments]). +-define(INFO_KEYS, [source_name, source_kind, + destination_name, destination_kind, + routing_key, arguments]). recover() -> rabbit_misc:table_fold( @@ -209,10 +211,12 @@ map(VHostPath, F) -> infos(Items, B) -> [{Item, i(Item, B)} || Item <- Items]. -i(source, #binding{source = SrcName}) -> SrcName; -i(destination, #binding{destination = DstName}) -> DstName; -i(routing_key, #binding{key = RoutingKey}) -> RoutingKey; -i(arguments, #binding{args = Arguments}) -> Arguments; +i(source_name, #binding{source = SrcName}) -> SrcName#resource.name; +i(source_kind, #binding{source = SrcName}) -> SrcName#resource.kind; +i(destination_name, #binding{destination = DstName}) -> DstName#resource.name; +i(destination_kind, #binding{destination = DstName}) -> DstName#resource.kind; +i(routing_key, #binding{key = RoutingKey}) -> RoutingKey; +i(arguments, #binding{args = Arguments}) -> Arguments; i(Item, _) -> throw({bad_argument, Item}). info(B = #binding{}) -> infos(?INFO_KEYS, B). diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl index e7050ef02d..2d62b999f0 100644 --- a/src/rabbit_control.erl +++ b/src/rabbit_control.erl @@ -257,16 +257,12 @@ action(list_exchanges, Node, Args, Opts, Inform) -> action(list_bindings, Node, Args, Opts, Inform) -> Inform("Listing bindings", []), VHostArg = list_to_binary(proplists:get_value(?VHOST_OPT, Opts)), - FormatFun = fun (#resource{name = Name, kind = Kind}) -> - "{" ++ format_info_item(Kind) ++ ": " ++ - format_info_item(Name) ++ "}" - end, - ArgAtoms = default_if_empty(Args, [source, destination, + ArgAtoms = default_if_empty(Args, [source_name, source_kind, + destination_name, destination_kind, routing_key, arguments]), display_info_list(rpc_call(Node, rabbit_binding, info_all, [VHostArg, ArgAtoms]), - ArgAtoms, [{source, FormatFun}, - {destination, FormatFun}]); + ArgAtoms); action(list_connections, Node, Args, _Opts, Inform) -> Inform("Listing connections", []), @@ -316,18 +312,14 @@ default_if_empty(List, Default) when is_list(List) -> [list_to_atom(X) || X <- List] end. -display_info_list(Results, InfoItemKeys) -> - display_info_list(Results, InfoItemKeys, []). - -display_info_list(Results, InfoItemKeys, FormatFuns) when is_list(Results) -> +display_info_list(Results, InfoItemKeys) when is_list(Results) -> lists:foreach( fun (Result) -> - display_row( - [(proplists:get_value(X, FormatFuns, fun format_info_item/1))( - proplists:get_value(X, Result)) || X <- InfoItemKeys]) + display_row([format_info_item(proplists:get_value(X, Result)) + || X <- InfoItemKeys]) end, Results), ok; -display_info_list(Other, _, _) -> +display_info_list(Other, _) -> Other. display_row(Row) -> |
