Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

patch bunnyc to survive a restart like gen_bunny can

  • Loading branch information...
commit af251d22bb560869994ca61a7d23ca274762d278 1 parent 0def22e
@boorad authored
Showing with 13 additions and 0 deletions.
  1. +3 −0  src/bunnyc.erl
  2. +10 −0 test/bunnyc_tests.erl
View
3  src/bunnyc.erl
@@ -135,6 +135,9 @@ handle_cast(_Request, State) ->
{noreply, State}.
+handle_info({reconnected, {ConnectionPid, ChannelPid}}, State) ->
+ {noreply, State#bunnyc_state{connection=ConnectionPid, channel=ChannelPid}};
+
handle_info(_Info, State) ->
{noreply, State}.
View
10 test/bunnyc_tests.erl
@@ -251,6 +251,16 @@ unknown_cast_test() ->
bunnyc:handle_cast(unknown_cast, #bunnyc_state{})).
+reconnected_info_test() ->
+ ConnectionPid = a,
+ ChannelPid = b,
+ {noreply, #bunnyc_state{connection=Conn, channel=Chan}} =
+ bunnyc:handle_info({reconnected, {ConnectionPid, ChannelPid}},
+ #bunnyc_state{}),
+ ?assertEqual(Conn, ConnectionPid),
+ ?assertEqual(Chan, ChannelPid).
+
+
unknown_info_test() ->
?assertEqual({noreply, #bunnyc_state{}},
bunnyc:handle_info(unknown_info, #bunnyc_state{})).
Please sign in to comment.
Something went wrong with that request. Please try again.