Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 1 commit
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
11 apps/dummy_app/ebin/dummy_app.appup
@@ -1,3 +1,14 @@
+{"3",
+ %% Upgrade instructions
+ [{"2", [
+ {update,dummy_app_server,{advanced,[from2to3]}}
+ ]}],
+ %% Downgrade instructions
+ [{"2",[
+ {update,dummy_app_server,{advanced,[from3to2]}}
+ ]}]
+}.
+
{"2",
%% Upgrade instructions from 1 to 2
[{"1", [
View
2  apps/dummy_app/src/dummy_app.app.src
@@ -1,7 +1,7 @@
{application, dummy_app,
[
{description, "Dummy project to test release process"},
- {vsn, "2"},
+ {vsn, "3"},
{registered, []},
{applications, [
kernel,
View
60 apps/dummy_app/src/dummy_app_server.erl
@@ -3,26 +3,35 @@
-behaviour(gen_server).
%% API
--export([start_link/0, poke/0, num_pokes/0, poke_twice/0]).
+%% API
+-export([ start_link/0
+ , poke/0
+ , poke/1
+ , poke_twice/0
+ , num_pokes/0
+ , prod/0
+ , prod/1
+ , num_prods/0
+ ]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
--record(state, {num_pokes = 0}).
+-record(state, {num_pokes = 0, num_prods = 0}).
%% API
-start_link() ->
- gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
+start_link() -> gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
-poke() ->
- gen_server:call(?MODULE, poke).
+poke() -> poke(1).
+poke_twice() -> poke(2).
+poke(N) -> gen_server:call(?MODULE, {poke, N}).
-poke_twice() ->
- gen_server:call(?MODULE, poke_twice).
+prod() -> prod(1).
+prod(N) -> gen_server:call(?MODULE, {prod, N}).
-num_pokes() ->
- gen_server:call(?MODULE, num_pokes).
+num_pokes() -> gen_server:call(?MODULE, num_pokes).
+num_prods() -> gen_server:call(?MODULE, num_prods).
%% gen_server callbacks
@@ -32,14 +41,17 @@ init([]) ->
handle_call(num_pokes, _From, State = #state{ num_pokes = PokeCount }) ->
{reply, PokeCount, State};
-handle_call(poke_twice, _From, State) ->
- NewPokeCount = State#state.num_pokes + 2,
- NewState = State#state{num_pokes = NewPokeCount},
- Reply = {ok, NewPokeCount},
+handle_call(num_prods, _From, State = #state{ num_prods = ProdCount }) ->
+ {reply, ProdCount, State};
+
+handle_call({prod, N}, _From, State) ->
+ NewProdCount = State#state.num_prods + N,
+ NewState = State#state{num_prods = NewProdCount},
+ Reply = {ok, NewProdCount},
{reply, Reply, NewState};
-handle_call(poke, _From, State) ->
- NewPokeCount = State#state.num_pokes + 1,
+handle_call({poke, N}, _From, State) ->
+ NewPokeCount = State#state.num_pokes + N,
NewState = State#state{num_pokes = NewPokeCount},
Reply = {ok, NewPokeCount},
{reply, Reply, NewState}.
@@ -53,9 +65,15 @@ handle_info(_Info, State) ->
terminate(_Reason, _State) ->
ok.
-code_change(OldVsn, State, Extra) ->
- error_logger:info_msg("code_change, oldvsn:~p state:~p extra:~p~n",
- [OldVsn, State, Extra]),
- {ok, State}.
+%% Upgrade from 2
+code_change(_OldVsn, State, [from2to3]) ->
+ error_logger:info_msg("CODE_CHANGE from 2~n"),
+ {state, NumPokes} = State, %% State here is the 'old' format, with 1 field
+ NewState = #state{num_pokes=NumPokes}, %% will assume default for num_prods
+ {ok, NewState}.
+
+%% Note downgrade code_change not implemented
+
+
-%%% Internal functions
+%%% Internal functions
View
2  rel/reltool.config
@@ -1,6 +1,6 @@
{sys, [
{lib_dirs, ["../apps"]},
- {rel, "dummy", "2",
+ {rel, "dummy", "3",
[
kernel,
stdlib,

No commit comments for this range

Something went wrong with that request. Please try again.