diff options
author | Simon MacMullen <simon@lshift.net> | 2010-04-12 13:52:57 +0100 |
---|---|---|
committer | Simon MacMullen <simon@lshift.net> | 2010-04-12 13:52:57 +0100 |
commit | c76f074ad679220dac767aa4000dba0e217b9fdd (patch) | |
tree | d405c6b696f8238ef6a003e9f3d50d8b9c089dbf | |
parent | 1bc29585c63c95708a7bc11fdb9a4b0ee3f3387d (diff) | |
download | rabbitmq-server-c76f074ad679220dac767aa4000dba0e217b9fdd.tar.gz |
Clean up exported function names.
-rw-r--r-- | src/delegate.erl | 49 | ||||
-rw-r--r-- | src/rabbit_amqqueue.erl | 38 | ||||
-rw-r--r-- | src/rabbit_router.erl | 4 | ||||
-rw-r--r-- | src/rabbit_tests.erl | 22 |
4 files changed, 56 insertions, 57 deletions
diff --git a/src/delegate.erl b/src/delegate.erl index a8d4ab31..76fd9d72 100644 --- a/src/delegate.erl +++ b/src/delegate.erl @@ -34,9 +34,9 @@ -behaviour(gen_server2). --export([start_link/1, delegate_cast/2, delegate_call/2, - delegate_gs2_call/3, delegate_gs2_pcall/4, - delegate_gs2_cast/2, delegate_gs2_pcast/3, +-export([start_link/1, cast/2, call/2, + gs2_call/3, gs2_pcall/4, + gs2_cast/2, gs2_pcast/3, server/1]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, @@ -51,55 +51,54 @@ start_link(Hash) -> gen_server2:start_link({local, server(Hash)}, ?MODULE, [], []). -delegate_gs2_call(Pid, Msg, Timeout) -> +gs2_call(Pid, Msg, Timeout) -> {_Status, Res} = - delegate_call(Pid, fun(P) -> gen_server2:call(P, Msg, Timeout) end), + call(Pid, fun(P) -> gen_server2:call(P, Msg, Timeout) end), Res. -delegate_gs2_pcall(Pid, Pri, Msg, Timeout) -> +gs2_pcall(Pid, Pri, Msg, Timeout) -> {_Status, Res} = - delegate_call(Pid, - fun(P) -> gen_server2:pcall(P, Pri, Msg, Timeout) end), + call(Pid, fun(P) -> gen_server2:pcall(P, Pri, Msg, Timeout) end), Res. -delegate_gs2_cast(Pid, Msg) -> - delegate_cast(Pid, fun(P) -> gen_server2:cast(P, Msg) end). +gs2_cast(Pid, Msg) -> + cast(Pid, fun(P) -> gen_server2:cast(P, Msg) end). -delegate_gs2_pcast(Pid, Pri, Msg) -> - delegate_cast(Pid, fun(P) -> gen_server2:pcast(P, Pri, Msg) end). +gs2_pcast(Pid, Pri, Msg) -> + cast(Pid, fun(P) -> gen_server2:pcast(P, Pri, Msg) end). % TODO reimplement the single-node optimisation -delegate_call(Node, Thunk) when is_atom(Node) -> +call(Node, Thunk) when is_atom(Node) -> gen_server2:call({server(), Node}, {thunk, Thunk}, infinity); -delegate_call(Pid, FPid) when is_pid(Pid) -> +call(Pid, FPid) when is_pid(Pid) -> [[{Status, Res, _}]] = delegate_per_node([{node(Pid), [Pid]}], - f_pid_node(fun delegate_call/2, FPid)), + f_pid_node(fun call/2, FPid)), {Status, Res}; -delegate_call(Pids, FPid) when is_list(Pids) -> +call(Pids, FPid) when is_list(Pids) -> lists:flatten( - delegate_per_node(split_per_node(Pids), - f_pid_node(fun delegate_call/2, FPid))). + delegate_per_node(split_delegate_per_node(Pids), + f_pid_node(fun call/2, FPid))). -delegate_cast(Node, Thunk) when is_atom(Node) -> +cast(Node, Thunk) when is_atom(Node) -> gen_server2:cast({server(), Node}, {thunk, Thunk}); -delegate_cast(Pid, FPid) when is_pid(Pid) -> +cast(Pid, FPid) when is_pid(Pid) -> delegate_per_node([{node(Pid), [Pid]}], - f_pid_node(fun delegate_cast/2, FPid)), + f_pid_node(fun cast/2, FPid)), ok; -delegate_cast(Pids, FPid) when is_list(Pids) -> - delegate_per_node(split_per_node(Pids), - f_pid_node(fun delegate_cast/2, FPid)), +cast(Pids, FPid) when is_list(Pids) -> + delegate_per_node(split_delegate_per_node(Pids), + f_pid_node(fun cast/2, FPid)), ok. %%---------------------------------------------------------------------------- -split_per_node(Pids) -> +split_delegate_per_node(Pids) -> dict:to_list( lists:foldl( fun (Pid, D) -> diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index f502b940..8c8a0e1f 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -234,10 +234,10 @@ info_keys() -> rabbit_amqqueue_process:info_keys(). map(VHostPath, F) -> rabbit_misc:filter_exit_map(F, list(VHostPath)). info(#amqqueue{ pid = QPid }) -> - delegate:delegate_gs2_pcall(QPid, 9, info, infinity). + delegate:gs2_pcall(QPid, 9, info, infinity). info(#amqqueue{ pid = QPid }, Items) -> - case delegate:delegate_gs2_pcall(QPid, 9, {info, Items}, infinity) of + case delegate:gs2_pcall(QPid, 9, {info, Items}, infinity) of {ok, Res} -> Res; {error, Error} -> throw(Error) end. @@ -247,7 +247,7 @@ info_all(VHostPath) -> map(VHostPath, fun (Q) -> info(Q) end). info_all(VHostPath, Items) -> map(VHostPath, fun (Q) -> info(Q, Items) end). consumers(#amqqueue{ pid = QPid }) -> - delegate:delegate_gs2_pcall(QPid, 9, consumers, infinity). + delegate:gs2_pcall(QPid, 9, consumers, infinity). consumers_all(VHostPath) -> lists:concat( @@ -256,16 +256,16 @@ consumers_all(VHostPath) -> {ChPid, ConsumerTag, AckRequired} <- consumers(Q)] end)). -stat(#amqqueue{pid = QPid}) -> delegate:delegate_gs2_call(QPid, stat, infinity). +stat(#amqqueue{pid = QPid}) -> delegate:gs2_call(QPid, stat, infinity). stat_all() -> lists:map(fun stat/1, rabbit_misc:dirty_read_all(rabbit_queue)). delete(#amqqueue{ pid = QPid }, IfUnused, IfEmpty) -> - delegate:delegate_gs2_call(QPid, {delete, IfUnused, IfEmpty}, infinity). + delegate:gs2_call(QPid, {delete, IfUnused, IfEmpty}, infinity). purge(#amqqueue{ pid = QPid }) -> - delegate:delegate_gs2_call(QPid, purge, infinity). + delegate:gs2_call(QPid, purge, infinity). deliver(QPid, #delivery{immediate = true, txn = Txn, sender = ChPid, message = Message}) -> @@ -280,13 +280,13 @@ deliver(QPid, #delivery{txn = Txn, sender = ChPid, message = Message}) -> true. redeliver(QPid, Messages) -> - delegate:delegate_gs2_cast(QPid, {redeliver, Messages}). + delegate:gs2_cast(QPid, {redeliver, Messages}). requeue(QPid, MsgIds, ChPid) -> - delegate:delegate_gs2_cast(QPid, {requeue, MsgIds, ChPid}). + delegate:gs2_cast(QPid, {requeue, MsgIds, ChPid}). ack(QPid, Txn, MsgIds, ChPid) -> - delegate:delegate_gs2_pcast(QPid, 7, {ack, Txn, MsgIds, ChPid}). + delegate:gs2_pcast(QPid, 7, {ack, Txn, MsgIds, ChPid}). commit_all(QPids, Txn) -> safe_delegate_call_ok( @@ -295,7 +295,7 @@ commit_all(QPids, Txn) -> QPids). rollback_all(QPids, Txn) -> - delegate:delegate_cast(QPids, + delegate:cast(QPids, fun (QPid) -> gen_server2:cast(QPid, {rollback, Txn}) end). notify_down_all(QPids, ChPid) -> @@ -307,34 +307,34 @@ notify_down_all(QPids, ChPid) -> QPids). limit_all(QPids, ChPid, LimiterPid) -> - delegate:delegate_cast(QPids, + delegate:cast(QPids, fun (QPid) -> gen_server2:cast(QPid, {limit, ChPid, LimiterPid}) end). claim_queue(#amqqueue{pid = QPid}, ReaderPid) -> - delegate:delegate_gs2_call(QPid, {claim_queue, ReaderPid}, infinity). + delegate:gs2_call(QPid, {claim_queue, ReaderPid}, infinity). basic_get(#amqqueue{pid = QPid}, ChPid, NoAck) -> - delegate:delegate_gs2_call(QPid, {basic_get, ChPid, NoAck}, infinity). + delegate:gs2_call(QPid, {basic_get, ChPid, NoAck}, infinity). basic_consume(#amqqueue{pid = QPid}, NoAck, ReaderPid, ChPid, LimiterPid, ConsumerTag, ExclusiveConsume, OkMsg) -> - delegate:delegate_gs2_call(QPid, {basic_consume, NoAck, ReaderPid, ChPid, + delegate:gs2_call(QPid, {basic_consume, NoAck, ReaderPid, ChPid, LimiterPid, ConsumerTag, ExclusiveConsume, OkMsg}, infinity). basic_cancel(#amqqueue{pid = QPid}, ChPid, ConsumerTag, OkMsg) -> - ok = delegate:delegate_gs2_call(QPid, + ok = delegate:gs2_call(QPid, {basic_cancel, ChPid, ConsumerTag, OkMsg}, infinity). notify_sent(QPid, ChPid) -> - delegate:delegate_gs2_pcast(QPid, 7, {notify_sent, ChPid}). + delegate:gs2_pcast(QPid, 7, {notify_sent, ChPid}). unblock(QPid, ChPid) -> - delegate:delegate_gs2_pcast(QPid, 7, {unblock, ChPid}). + delegate:gs2_pcast(QPid, 7, {unblock, ChPid}). flush_all(QPids, ChPid) -> - delegate:delegate_cast(QPids, + delegate:cast(QPids, fun (QPid) -> gen_server2:cast(QPid, {flush, ChPid}) end). internal_delete(QueueName) -> @@ -382,7 +382,7 @@ pseudo_queue(QueueName, Pid) -> pid = Pid}. safe_delegate_call_ok(H, F, Pids) -> - case [R || R = {error, _, _} <- delegate:delegate_call( + case [R || R = {error, _, _} <- delegate:call( Pids, fun (Pid) -> rabbit_misc:with_exit_handler( diff --git a/src/rabbit_router.erl b/src/rabbit_router.erl index 8c4da5f3..5fd5715b 100644 --- a/src/rabbit_router.erl +++ b/src/rabbit_router.erl @@ -56,12 +56,12 @@ deliver(QPids, Delivery = #delivery{mandatory = false, %% therefore safe to use a fire-and-forget cast here and return %% the QPids - the semantics is preserved. This scales much better %% than the non-immediate case below. - delegate:delegate_cast(QPids, + delegate:cast(QPids, fun(Pid) -> rabbit_amqqueue:deliver(Pid, Delivery) end), {routed, QPids}; deliver(QPids, Delivery) -> - Res = delegate:delegate_call(QPids, + Res = delegate:call(QPids, fun(Pid) -> rabbit_amqqueue:deliver(Pid, Delivery) end), {Routed, Handled} = lists:foldl(fun fold_deliveries/2, {false, []}, Res), diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index 297803f9..b5efd2d4 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -830,13 +830,13 @@ test_delegates_async() -> end end, - ok = delegate:delegate_cast(spawn(Receiver), Sender), - ok = delegate:delegate_cast(spawn(SecondaryNode, Receiver), Sender), + ok = delegate:cast(spawn(Receiver), Sender), + ok = delegate:cast(spawn(SecondaryNode, Receiver), Sender), await_response(2), LocalPids = [spawn(Receiver) || _ <- lists:seq(1,10)], RemotePids = [spawn(SecondaryNode, Receiver) || _ <- lists:seq(1,10)], - ok = delegate:delegate_cast(LocalPids ++ RemotePids, Sender), + ok = delegate:cast(LocalPids ++ RemotePids, Sender), await_response(20), passed. @@ -855,8 +855,8 @@ await_response(Count) -> test_delegates_sync() -> SecondaryNode = rabbit_misc:makenode("hare"), - {ok, "foo"} = delegate:delegate_call(node(), fun() -> "foo" end), - {ok, "bar"} = delegate:delegate_call(SecondaryNode, fun() -> "bar" end), + {ok, "foo"} = delegate:call(node(), fun() -> "foo" end), + {ok, "bar"} = delegate:call(SecondaryNode, fun() -> "bar" end), Sender = fun(Pid) -> gen_server2:call(Pid, invoked) @@ -882,22 +882,22 @@ test_delegates_sync() -> end end, - {ok, response} = delegate:delegate_call(spawn(Responder), Sender), - {ok, response} = delegate:delegate_call(spawn(SecondaryNode, Responder), Sender), + {ok, response} = delegate:call(spawn(Responder), Sender), + {ok, response} = delegate:call(spawn(SecondaryNode, Responder), Sender), - {error, _} = delegate:delegate_call(spawn(BadResponder), Sender), - {error, _} = delegate:delegate_call(spawn(SecondaryNode, BadResponder), Sender), + {error, _} = delegate:call(spawn(BadResponder), Sender), + {error, _} = delegate:call(spawn(SecondaryNode, BadResponder), Sender), LocalGoodPids = [spawn(Responder) || _ <- lists:seq(1,2)], RemoteGoodPids = [spawn(Responder) || _ <- lists:seq(1,2)], LocalBadPids = [spawn(SecondaryNode, BadResponder) || _ <- lists:seq(1,2)], RemoteBadPids = [spawn(SecondaryNode, BadResponder) || _ <- lists:seq(1,2)], - GoodRes = delegate:delegate_call(LocalGoodPids ++ RemoteGoodPids, Sender), + GoodRes = delegate:call(LocalGoodPids ++ RemoteGoodPids, Sender), [{ok, response, _}, {ok, response, _}, {ok, response, _}, {ok, response, _}] = GoodRes, - BadRes = delegate:delegate_call(LocalBadPids ++ RemoteBadPids, Sender), + BadRes = delegate:call(LocalBadPids ++ RemoteBadPids, Sender), [{error, _, _}, {error, _, _}, {error, _, _}, {error, _, _}] = BadRes, |