Code loading
| code_change/3 | |
| term_to_binary/1 | |
| Relup in practice | |
| Old version module |
code_change/3
When a new version of a module is loaded, code_change/3 is called. It receives the old version number, the old state, and the new version number, and must return new state.
-module(counter).
-behaviour(gen_server).
-init([]) -> {ok, 0}.
-handle_info({upgrade, _OldVsn, _OldState}) -> {ok, State}.
-code_change(_OldVsn, OldState, _NewVsn) -> {ok, OldState}.
Next: Distributed Erlang
Article author: Arthur Isaev