terminate(_Reason, _State) ->
ok.
-code_change(3, State, ok) ->
- RoutingKey = get_routing_key(State#irc_state.instance),
- AmqpListener = irc_object_sup:get_amqp_listener(
- State#irc_state.object_sup,
- RoutingKey),
- case AmqpListener of
- {error, notfound} -> ok;
- Pid -> irc_amqp_listener:stop(Pid)
- end,
- irc_object_sup:delete_amqp_listener(
- State#irc_state.object_sup,
- RoutingKey),
- gen_server:cast(self(), create_object_sup),
- {ok, State};
+code_change(4, OldState, ok) ->
+ NewState = list_to_tuple(tuple_to_list(OldState) ++ [none]),
+ error_logger:info_msg("Updating irc state from ~p to ~p~n", [OldState, NewState]),
+ {ok, NewState};
-code_change({down, 3}, State, ok) ->
- RoutingKey = get_routing_key(State#irc_state.instance),
- % Downgrade doesn't need to ask the irc_amqp_listener to stop gracefully,
- % since the childspec actually allows it to terminate itself cleanly.
- irc_object_sup:delete_amqp_listener(
- State#irc_state.object_sup,
- RoutingKey),
- gen_server:cast(self(), create_object_sup),
- {ok, State};
+code_change({down, 4}, State, ok) ->
+ {ok, list_to_tuple(lists:sublist(tuple_to_list(State), 9))};
code_change(_OldVsn, _State, _Extra) ->
{error, unsupported}.