diff options
| author | Ben Hood <0x6e6562@gmail.com> | 2008-08-05 17:29:08 +0100 |
|---|---|---|
| committer | Ben Hood <0x6e6562@gmail.com> | 2008-08-05 17:29:08 +0100 |
| commit | 848a8b10e7548849427483d30a32df0e73fc32c7 (patch) | |
| tree | 5648db4ca11da2b3bb1407679b10c1b1ce089a3f | |
| parent | 8834453890e058115bdd53671029e34ffc0b0a08 (diff) | |
| download | rabbitmq-server-git-848a8b10e7548849427483d30a32df0e73fc32c7.tar.gz | |
Renamed the routing fields to keep the naming conventions consistent
| -rw-r--r-- | include/rabbit.hrl | 21 | ||||
| -rw-r--r-- | src/rabbit_amqqueue.erl | 5 | ||||
| -rw-r--r-- | src/rabbit_exchange.erl | 37 | ||||
| -rw-r--r-- | src/rabbit_mnesia.erl | 8 |
4 files changed, 35 insertions, 36 deletions
diff --git a/include/rabbit.hrl b/include/rabbit.hrl index 44268940e8..418d6521a0 100644 --- a/include/rabbit.hrl +++ b/include/rabbit.hrl @@ -31,11 +31,11 @@ -record(connection, {user, timeout_sec, frame_max, vhost}). -record(content, {class_id, - properties, %% either 'none', or a decoded record/tuple - properties_bin, %% either 'none', or an encoded properties binary - %% Note: at most one of properties and properties_bin can be 'none' at once. - payload_fragments_rev %% list of binaries, in reverse order (!) - }). + properties, %% either 'none', or a decoded record/tuple + properties_bin, %% either 'none', or an encoded properties binary + %% Note: at most one of properties and properties_bin can be 'none' at once. + payload_fragments_rev %% list of binaries, in reverse order (!) + }). -record(resource, {virtual_host, kind, name}). @@ -46,11 +46,12 @@ %% ets, which stores key value pairs %% The binding field is made up of an {Exchange, Binding, Queue} --record(forwards_binding, {binding, value = const}). -%% The binding field is made up of an {Queue, Binding, Exchange} --record(reverse_binding, {binding, value = const}). +-record(route, {binding, value = const}). +%% The reverse_binding field is made up of an {Queue, Binding, Exchange} +-record(reverse_route, {reverse_binding, value = const}). --record(binding, {virtual_host, exchange_name, key, queue_name}). +-record(binding, {exchange_name, key, queue_name}). +-record(reverse_binding, {queue_name, key, exchange_name}). -record(listener, {node, protocol, host, port}). @@ -80,7 +81,7 @@ -type(user() :: #user{username :: username(), password :: password()}). --type(permission() :: 'passive' | 'active' | 'write' | 'read'). +-type(permission() :: 'passive' | 'active' | 'write' | 'read'). -type(amqqueue() :: #amqqueue{name :: queue_name(), durable :: bool(), diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index ad17a42eb2..51b740c671 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -138,7 +138,7 @@ declare(Resource = #resource{}, Durable, AutoDelete, Args) -> pid = none}), case rabbit_misc:execute_mnesia_transaction( fun () -> - case mnesia:wread({amqqueue, Resource}) of + case mnesia:wread({amqqueue, Resource}) of [] -> ok = recover_queue(Q), Q; [ExistingQ] -> ExistingQ @@ -169,8 +169,7 @@ recover_queue(Q) -> default_binding_spec(#resource{virtual_host = VHostPath, name = Name}) -> #binding{exchange_name = <<"">>, key = Name, - queue_name = Name, - virtual_host = VHostPath}. + queue_name = Name}. % #binding_spec{exchange_name = rabbit_misc:r(VHostPath,exchange,<<"">>), % routing_key = Name, % arguments = []}. diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index eb8977f9b4..ab4d7568d4 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -53,18 +53,18 @@ -spec(declare/5 :: (name(), exchange_type(), bool(), bool(), amqp_table()) -> exchange()). -spec(check_type/1 :: (binary()) -> atom()). --spec(assert_type/2 :: (exchange(), atom()) -> 'ok'). +-spec(assert_type/2 :: (exchange(), atom()) -> 'ok'). -spec(lookup/1 :: (exchange_name()) -> {'ok', exchange()} | not_found()). -spec(lookup_or_die/1 :: (exchange_name()) -> exchange()). -spec(list_vhost_exchanges/1 :: (vhost()) -> [exchange()]). --spec(list_exchange_bindings/1 :: (exchange_name()) -> +-spec(list_exchange_bindings/1 :: (exchange_name()) -> [{queue_name(), routing_key(), amqp_table()}]). -spec(simple_publish/6 :: (bool(), bool(), exchange_name(), routing_key(), binary(), binary()) -> publish_res()). -spec(simple_publish/3 :: (bool(), bool(), message()) -> publish_res()). -spec(route/2 :: (exchange(), routing_key()) -> [pid()]). -% -spec(add_binding/2 :: (binding_spec(), amqqueue()) -> +% -spec(add_binding/2 :: (binding_spec(), amqqueue()) -> % 'ok' | not_found() | % {'error', 'durability_settings_incompatible'}). % -spec(delete_binding/2 :: (binding_spec(), amqqueue()) -> @@ -150,7 +150,7 @@ list_exchange_bindings(Name) -> % #handler{binding_spec = #binding_spec{routing_key = RoutingKey, % arguments = Arguments}, % queue = QueueName} <- Handlers]. - + bindings_for_exchange(Name) -> exit(bindings_for_exchange). % qlc:e(qlc:q([B || B = #binding{key = K} <- mnesia:table(binding), @@ -186,7 +186,7 @@ simple_publish(Mandatory, Immediate, %% return the list of qpids to which a message with a given routing %% key, sent to a particular exchange, should be delivered. -%% +%% %% The function ensures that a qpid appears in the return list exactly %% as many times as a message should be delivered to it. With the %% current exchange types that is at most once. @@ -197,7 +197,7 @@ route(#exchange{name = Name, type = topic}, RoutingKey) -> % mnesia:activity( % async_dirty, % fun () -> - % qlc:e(qlc:q([handler_qpids(H) || + % qlc:e(qlc:q([handler_qpids(H) || % #binding{key = {Name1, PatternKey}, % handlers = H} % <- mnesia:table(binding), @@ -221,15 +221,15 @@ delivery_key_for_type(_Type, Name, RoutingKey) -> % Don't really like this double lookup % It seems very clunky % Can this get refactored to to avoid the duplication of the lookup/1 function? -call_with_exchange_and_queue(#binding{virtual_host = VHost, exchange_name = Exchange, +call_with_exchange_and_queue(#binding{exchange_name = Exchange, queue_name = Queue}, Fun) -> io:format("Reading (~p) and (~p) ~n",[Exchange,Queue]), - case mnesia:wread({exchange, rabbit_misc:r(VHost, exchange, Exchange)}) of + case mnesia:wread({exchange, Exchange}) of [] -> {error, exchange_not_found}; - [X] -> - case mnesia:wread({amqqueue, rabbit_misc:r(VHost, amqqueue, Queue)}) of + [X] -> + case mnesia:wread({amqqueue, Queue}) of [] -> {error, queue_not_found}; - [Q] -> + [Q] -> Fun(X,Q) end end. @@ -250,7 +250,7 @@ add_binding(Binding) -> end). delete_binding(BindingSpec %= #binding_spec{exchange_name = ExchangeName, - % routing_key = RoutingKey}, + % routing_key = RoutingKey}, ,Q) -> exit(delete_binding). % call_with_exchange( @@ -280,17 +280,16 @@ handler_qpids(Handlers) -> exit(handler_qpids). %sets:from_list([QPid || #handler{qpid = QPid} <- Handlers]). -reverse_binding(#binding{virtual_host = VHost, exchange_name = Exchange, - key = Key, queue_name = Queue}) -> - {binding, VHost, Queue, Key, Exchange}. +reverse_binding(#binding{exchange_name = Exchange, key = Key, queue_name = Queue}) -> + #reverse_binding{exchange_name = Exchange, key = Key, queue_name = Queue}. %% Must run within a transaction. internal_add_binding(Binding) -> - Forwards = #forwards_binding{ binding = Binding }, - Reverse = #reverse_binding{ binding = reverse_binding(Binding) }, + Forwards = #route{ binding = Binding }, + Reverse = #reverse_route{ reverse_binding = reverse_binding(Binding) }, ok = mnesia:write(Forwards), ok = mnesia:write(Reverse). - + %% Must run within a transaction. internal_delete_binding(#exchange{name = ExchangeName, type = Type}, RoutingKey, Handler) -> BindingKey = delivery_key_for_type(Type, ExchangeName, RoutingKey), @@ -310,7 +309,7 @@ add_handler_to_binding(BindingKey, Handler) -> % ok = mnesia:write( % B#binding{handlers = extend_handlers(H, Handler)}) % end. - + %% Must run within a transaction. remove_handler_from_binding(BindingKey, Handler) -> exit(remove_handler_from_binding). diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl index 0420a416d4..f7c497f741 100644 --- a/src/rabbit_mnesia.erl +++ b/src/rabbit_mnesia.erl @@ -105,8 +105,8 @@ table_definitions() -> {rabbit_config, [{disc_copies, [node()]}]}, {listener, [{type, bag}, {attributes, record_info(fields, listener)}]}, - {forwards_binding, [{type,ordered_set},{attributes, record_info(fields, forwards_binding)}]}, - {reverse_binding, [{type,ordered_set},{attributes, record_info(fields, reverse_binding)}]}, + {route, [{type,ordered_set},{attributes, record_info(fields, route)}]}, + {reverse_route, [{type,ordered_set},{attributes, record_info(fields, reverse_route)}]}, {durable_exchanges, [{disc_copies, [node()]}, {record_name, exchange}, {attributes, record_info(fields, exchange)}]}, @@ -257,7 +257,7 @@ init_db(ClusterNodes) -> end. create_schema() -> - mnesia:stop(), + mnesia:stop(), rabbit_misc:ensure_ok(mnesia:create_schema([node()]), cannot_create_schema), rabbit_misc:ensure_ok(mnesia:start(), @@ -324,7 +324,7 @@ create_local_table_copy(Tab, Type) -> end, ok. -wait_for_tables() -> +wait_for_tables() -> case mnesia:wait_for_tables(table_names(), 30000) of ok -> ok; {timeout, BadTabs} -> |
