diff options
author | Matthias Radestock <matthias@lshift.net> | 2010-02-04 03:38:56 +0000 |
---|---|---|
committer | Matthias Radestock <matthias@lshift.net> | 2010-02-04 03:38:56 +0000 |
commit | 7d507d3dac7befd28edcb08fca716faa475c442b (patch) | |
tree | 3f33dc6de56c7cf373b9a52d4420c9c9ee26716c | |
parent | 02755e4d9928fe05c1a25e1ec44f3e16299b0dcb (diff) | |
download | rabbitmq-server-7d507d3dac7befd28edcb08fca716faa475c442b.tar.gz |
add pg_local:sync helper function for testing
turns out that making any kind of assertions when everything is async
is pretty much impossible
-rw-r--r-- | src/pg_local.erl | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/pg_local.erl b/src/pg_local.erl index 7f771f74..fa41fe46 100644 --- a/src/pg_local.erl +++ b/src/pg_local.erl @@ -35,6 +35,7 @@ -module(pg_local). -export([join/2, leave/2, get_members/1]). +-export([sync/0]). %% intended for testing only; not part of official API -export([start/0,start_link/0,init/1,handle_call/3,handle_cast/2,handle_info/2, terminate/2]). @@ -50,6 +51,8 @@ -spec(leave/2 :: (name(), pid()) -> 'ok'). -spec(get_members/1 :: (name()) -> [pid()]). +-spec(sync/0 :: () -> 'ok'). + -endif. %%---------------------------------------------------------------------------- @@ -78,6 +81,10 @@ get_members(Name) -> ensure_started(), group_members(Name). +sync() -> + ensure_started(), + gen_server:call(?MODULE, sync). + %%% %%% Callback functions from gen_server %%% @@ -88,6 +95,9 @@ init([]) -> pg_local_table = ets:new(pg_local_table, [ordered_set, protected, named_table]), {ok, #state{}}. +handle_call(sync, _From, S) -> + {reply, ok, S}; + handle_call(Request, From, S) -> error_logger:warning_msg("The pg_local server received an unexpected message:\n" "handle_call(~p, ~p, _)\n", |