Skip to content
Browse files

Hans Svensson's new gen_leader. Leader election bug solved

  • Loading branch information...
1 parent be5c4ab commit abaf7ee3a01af1a735aaed91d31b2e46f5785ccb uwiger committed
View
11 lib/gen_leader/Makefile
@@ -7,13 +7,14 @@ DOCDIR=doc
EDOCDIR="../edoc/ebin"
STOOLSDIR="../syntax_tools/ebin"
XMERLDIR="../xmerl/ebin"
-DOC_OPTS=[{title,"Welcome to gen_leader"}]
+DOCDIR=doc
+DOC_OPTS=[{title,"Welcome to gen_leader"},{hidden,false},{private,false}]
+
+all: all-subdirs docs
-all: all-subdirs
-# Commented out since the new edoc is not yet in jungerl.
-#docs:
-# erl -noshell -pa $(EDOCDIR) -pz $(STOOLSDIR) -pz $(XMERLDIR) -run edoc_run application "'$(APPNAME)'" '"."' '$(DOC_OPTS)' -s erlang halt
+docs:
+ erl -noshell -run edoc_run application "'$(APPNAME)'" '"."' '$(DOC_OPTS)' -s erlang halt
all-subdirs:
@for dir in $(SUBDIRS); do \
View
32 lib/gen_leader/doc/gdict.html
@@ -29,67 +29,67 @@
<h2><a name="functions">Function Details</a></h2>
<h3><a name="append-3">append/3</a></h3>
-<tt>append(Key, Value, Dict) -> term()
+<tt>append(Key, Value, Dict) -&gt; term()
</tt>
<h3><a name="append_list-3">append_list/3</a></h3>
-<tt>append_list(Key, ValList, Dict) -> term()
+<tt>append_list(Key, ValList, Dict) -&gt; term()
</tt>
<h3><a name="erase-2">erase/2</a></h3>
-<tt>erase(Key, Dict) -> term()
+<tt>erase(Key, Dict) -&gt; term()
</tt>
<h3><a name="fetch-2">fetch/2</a></h3>
-<tt>fetch(Key, Dict) -> term()
+<tt>fetch(Key, Dict) -&gt; term()
</tt>
<h3><a name="fetch_keys-1">fetch_keys/1</a></h3>
-<tt>fetch_keys(Dict) -> term()
+<tt>fetch_keys(Dict) -&gt; term()
</tt>
<h3><a name="filter-2">filter/2</a></h3>
-<tt>filter(Pred, Dict) -> term()
+<tt>filter(Pred, Dict) -&gt; term()
</tt>
<h3><a name="find-2">find/2</a></h3>
-<tt>find(Key, Dict) -> term()
+<tt>find(Key, Dict) -&gt; term()
</tt>
<h3><a name="fold-3">fold/3</a></h3>
-<tt>fold(Fun, Acc0, Dict) -> term()
+<tt>fold(Fun, Acc0, Dict) -&gt; term()
</tt>
<h3><a name="is_key-2">is_key/2</a></h3>
-<tt>is_key(Key, Dict) -> term()
+<tt>is_key(Key, Dict) -&gt; term()
</tt>
<h3><a name="map-2">map/2</a></h3>
-<tt>map(Fun, Dict) -> term()
+<tt>map(Fun, Dict) -&gt; term()
</tt>
<h3><a name="new-3">new/3</a></h3>
-<tt>new(Name, Candidates, Workers) -> term()
+<tt>new(Name, Candidates, Workers) -&gt; term()
</tt>
<h3><a name="store-3">store/3</a></h3>
-<tt>store(Key, Value, Dict) -> term()
+<tt>store(Key, Value, Dict) -&gt; term()
</tt>
<h3><a name="to_list-1">to_list/1</a></h3>
-<tt>to_list(Dict) -> term()
+<tt>to_list(Dict) -&gt; term()
</tt>
<h3><a name="update-3">update/3</a></h3>
-<tt>update(Key, Function, Dict) -> term()
+<tt>update(Key, Function, Dict) -&gt; term()
</tt>
<h3><a name="update-4">update/4</a></h3>
-<tt>update(Key, Function, Initial, Dict) -> term()
+<tt>update(Key, Function, Initial, Dict) -&gt; term()
</tt>
<h3><a name="update_counter-3">update_counter/3</a></h3>
-<tt>update_counter(Key, Incr, Dict) -> term()
+<tt>update_counter(Key, Incr, Dict) -&gt; term()
</tt>
</body>
</html>
View
75 lib/gen_leader/doc/gen_leader.html
@@ -6,26 +6,35 @@
</head>
<body bgcolor="white">
<h1>Module gen_leader</h1>
-Leader election behaviour.<ul><li><a href="#description">Description</a></li><li><a href="#types">Data Types</a></li><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul><p><b>Authors:</b> Ulf Wiger (<a href="mailto:ulf.wiger@ericsson.com"><tt>ulf.wiger@ericsson.com</tt></a>), Thomas Arts (<a href="mailto:thomas.arts@ituniv.se"><tt>thomas.arts@ituniv.se</tt></a>).</p>
-<h2><a name="description">Description</a></h2>Leader election behaviour.
- <p>This application implements a leader election behaviour modeled after
- gen_server. This behaviour intends to make it reasonably
- straightforward to implement a fully distributed server with
- master-slave semantics.</p>
- <p>The gen_leader behaviour supports nearly everything that gen_server
- does (some functions, such as multicall() and the internal timeout,
- have been removed), and adds a few callbacks and API functions to
- support leader election etc.</p>
- <p>Also included is an example program, a global dictionary, based
- on the modules gen_leader and dict. The callback implementing the
- global dictionary is called 'test_cb', for no particularly logical
- reason.</p>
+Leader election behavior.<ul><li><a href="#description">Description</a></li><li><a href="#types">Data Types</a></li><li><a href="#index">Function Index</a></li><li><a href="#functions">Function Details</a></li></ul><p><b>Authors:</b> Hans Svensson (<a href="mailto:hanssv@cs.chalmers.se"><tt>hanssv@cs.chalmers.se</tt></a>), Thomas Arts (<a href="mailto:thomas.arts@ituniv.se"><tt>thomas.arts@ituniv.se</tt></a>), Ulf Wiger (<a href="mailto:ulf.wiger@ericsson.com"><tt>ulf.wiger@ericsson.com</tt></a>).</p>
+<h2><a name="description">Description</a></h2>Leader election behavior.
+ <p>This application implements a leader election behavior modeled after
+ gen_server. This behavior intends to make it reasonably
+ straightforward to implement a fully distributed server with
+ master-slave semantics.</p>
+ <p>The gen_leader behavior supports nearly everything that gen_server
+ does (some functions, such as multicall() and the internal timeout,
+ have been removed), and adds a few callbacks and API functions to
+ support leader election etc.</p>
+ <p>Also included is an example program, a global dictionary, based
+ on the modules gen_leader and dict. The callback implementing the
+ global dictionary is called 'test_cb', for no particularly logical
+ reason.</p>
+ <p><b>New version:</b> The internal leader election algorithm was faulty
+ and has been replaced with a new version based on a different leader
+ election algorithm. As a consequence of this the query functions
+ <tt>alive</tt> and <tt>down</tt> can no longer be provided.
+ The new algorithm also make use of an incarnation parameter, by
+ default written to disk in the function <tt>incarnation</tt>. This
+ implies that only one <tt>gen_leader</tt> per node is permitted, if
+ used in a diskless environment, <tt>incarnation</tt> must be adapted.
+ </p>
<h2><a name="types">Data Types</a></h2>
<h3><a name="type-callerRef">callerRef()</a></h3>
<p><tt>callerRef() = {pid(), reference()}</tt></p>
<p>See gen_server.
- </p>
+ </p>
<h3><a name="type-election">election()</a></h3>
<p><tt>election() = tuple()</tt></p>
@@ -44,15 +53,13 @@
<p>See gen_server.</p>
<h2><a name="index">Function Index</a></h2>
-<table width="100%" border="1"><tr><td valign="top"><a href="#alive-1">alive/1</a></td><td>Returns a list of live nodes (candidates and workers).</td></tr>
-<tr><td valign="top"><a href="#call-2">call/2</a></td><td>Equivalent to <code>gen_server:call/2</code>, but with a slightly
+<table width="100%" border="1"><tr><td valign="top"><a href="#call-2">call/2</a></td><td>Equivalent to <code>gen_server:call/2</code>, but with a slightly
different exit reason if something goes wrong.</td></tr>
<tr><td valign="top"><a href="#call-3">call/3</a></td><td>Equivalent to <code>gen_server:call/3</code>, but with a slightly
different exit reason if something goes wrong.</td></tr>
<tr><td valign="top"><a href="#candidates-1">candidates/1</a></td><td>Returns a list of known candidates.</td></tr>
<tr><td valign="top"><a href="#cast-2">cast/2</a></td><td><p>Equivalent to <tt>gen_server:cast / 2</tt>.</p>
</td></tr>
-<tr><td valign="top"><a href="#down-1">down/1</a></td><td>Returns a list of candidates currently not running.</td></tr>
<tr><td valign="top"><a href="#leader_call-2">leader_call/2</a></td><td>Makes a call (similar to <code>gen_server:call/2</code>) to the
leader.</td></tr>
<tr><td valign="top"><a href="#leader_call-3">leader_call/3</a></td><td>Makes a call (similar to <code>gen_server:call/3</code>) to the
@@ -68,20 +75,15 @@
<h2><a name="functions">Function Details</a></h2>
-<h3><a name="alive-1">alive/1</a></h3>
-<p><tt>alive(E::<a href="#type-election">election()</a>) -> [<a href="#type-node">node()</a>]</tt></p>
-<p>Returns a list of live nodes (candidates and workers).
- </p>
-
<h3><a name="call-2">call/2</a></h3>
-<p><tt>call(Name::<a href="#type-serverRef">serverRef()</a>, Request::Request) -> term()</tt></p>
+<p><tt>call(Name::<a href="#type-serverRef">serverRef()</a>, Request) -&gt; term()</tt></p>
<p>Equivalent to <code>gen_server:call/2</code>, but with a slightly
different exit reason if something goes wrong. This function calls
the <code>gen_leader</code> process exactly as if it were a gen_server
(which, for practical purposes, it is.)</p>
<h3><a name="call-3">call/3</a></h3>
-<p><tt>call(Name::<a href="#type-serverRef">serverRef()</a>, Request::Request, Timeout::integer()) -> Reply</tt>
+<p><tt>call(Name::<a href="#type-serverRef">serverRef()</a>, Request, Timeout::integer()) -&gt; Reply</tt>
<ul><li><tt>Reply = term()</tt></li></ul></p>
<p>Equivalent to <code>gen_server:call/3</code>, but with a slightly
different exit reason if something goes wrong. This function calls
@@ -89,22 +91,17 @@
(which, for practical purposes, it is.)</p>
<h3><a name="candidates-1">candidates/1</a></h3>
-<p><tt>candidates(E::<a href="#type-election">election()</a>) -> [<a href="#type-node">node()</a>]</tt></p>
+<p><tt>candidates(E::<a href="#type-election">election()</a>) -&gt; [<a href="#type-node">node()</a>]</tt></p>
<p>Returns a list of known candidates.
</p>
<h3><a name="cast-2">cast/2</a></h3>
-<tt>cast(Name, Request) -> term()
+<tt>cast(Name, Request) -&gt; term()
</tt><p>Equivalent to <tt>gen_server:cast / 2</tt>.</p>
-<h3><a name="down-1">down/1</a></h3>
-<p><tt>down(E::<a href="#type-election">election()</a>) -> [<a href="#type-node">node()</a>]</tt></p>
-<p>Returns a list of candidates currently not running.
- </p>
-
<h3><a name="leader_call-2">leader_call/2</a></h3>
-<p><tt>leader_call(Name::<a href="#type-name">name()</a>, Request::term()) -> Reply</tt>
+<p><tt>leader_call(Name::<a href="#type-name">name()</a>, Request::term()) -&gt; Reply</tt>
<ul><li><tt>Reply = term()</tt></li></ul></p>
<p>Makes a call (similar to <code>gen_server:call/2</code>) to the
leader. The call is forwarded via the local gen_leader instance, if
@@ -114,7 +111,7 @@
same default timeout as e.g. <code>gen_server:call/2</code>.</p></p>
<h3><a name="leader_call-3">leader_call/3</a></h3>
-<p><tt>leader_call(Name::<a href="#type-name">name()</a>, Request::term(), Timeout::integer()) -> Reply</tt>
+<p><tt>leader_call(Name::<a href="#type-name">name()</a>, Request::term(), Timeout::integer()) -&gt; Reply</tt>
<ul><li><tt>Reply = term()</tt></li></ul></p>
<p>Makes a call (similar to <code>gen_server:call/3</code>) to the
leader. The call is forwarded via the local gen_leader instance, if
@@ -122,22 +119,22 @@
leader dies while the request is outstanding.</p>
<h3><a name="leader_cast-2">leader_cast/2</a></h3>
-<p><tt>leader_cast(Name::<a href="#type-name">name()</a>, Msg::term()) -> ok</tt></p>
+<p><tt>leader_cast(Name::<a href="#type-name">name()</a>, Msg::term()) -&gt; ok</tt></p>
<p>Similar to <code>gen_server:cast/2</code> but will be forwarded to
the leader via the local gen_leader instance.</p>
<h3><a name="reply-2">reply/2</a></h3>
-<p><tt>reply(From::<a href="#type-callerRef">callerRef()</a>, Reply::term()) -> Void</tt></p>
+<p><tt>reply(From::<a href="#type-callerRef">callerRef()</a>, Reply::term()) -&gt; Void</tt></p>
<p>Equivalent to <tt>gen_server:reply / 2</tt>.</p>
<h3><a name="start-6">start/6</a></h3>
-<p><tt>start(Name::<a href="#type-node">node()</a>, CandidateNodes::[<a href="#type-node">node()</a>], Workers::[<a href="#type-node">node()</a>], Mod::atom(), Arg::Arg, Options::list()) -> {ok, pid()}</tt></p>
+<p><tt>start(Name::<a href="#type-node">node()</a>, CandidateNodes::[<a href="#type-node">node()</a>], Workers::[<a href="#type-node">node()</a>], Mod::atom(), Arg, Options::list()) -&gt; {ok, pid()}</tt></p>
<p>Starts a gen_leader process without linking to the parent.
</p>
<h3><a name="start_link-6">start_link/6</a></h3>
-<p><tt>start_link(Name::atom(), CandidateNodes::[atom()], Workers::[atom()], Mod::atom(), Arg::Arg, Options::list()) -> {ok, pid()}</tt></p>
+<p><tt>start_link(Name::atom(), CandidateNodes::[atom()], Workers::[atom()], Mod::atom(), Arg, Options::list()) -&gt; {ok, pid()}</tt></p>
<p>Starts a gen_leader process.
<table>
<tr><td>Name</td><td>The locally registered name of the process</td></tr>
@@ -155,7 +152,7 @@
can be added at runtime.</p></p>
<h3><a name="workers-1">workers/1</a></h3>
-<p><tt>workers(E::<a href="#type-election">election()</a>) -> [<a href="#type-node">node()</a>]</tt></p>
+<p><tt>workers(E::<a href="#type-election">election()</a>) -&gt; [<a href="#type-node">node()</a>]</tt></p>
<p>Returns a list of known workers.
</p>
</body>
View
8 lib/gen_leader/doc/index.html
@@ -1,16 +1,16 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
-<title>The gen_leader application</title>
+<title>Welcome to gen_leader</title>
</head>
<frameset cols="20%,80%">
<frame src="modules-frame.html" name="modulesFrame" title="">
<frame src="overview-summary.html" name="overviewFrame" title="">
<noframes>
-<h2>Yo, man!</h2>
-<p>Your browser does not dig frames, man!
-<br>You should be going to the <a href="overview-summary.html">non-frame version</a> instead.
+<h2>This page uses frames</h2>
+<p>Your browser does not accept frames.
+<br>You should go to the <a href="overview-summary.html">non-frame version</a> instead.
</p>
</noframes>
</frameset>
View
2 lib/gen_leader/doc/modules-frame.html
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
-<title>The gen_leader application</title>
+<title>Welcome to gen_leader</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body bgcolor="white">
View
99 lib/gen_leader/doc/overview-summary.html
@@ -1,105 +1,10 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
-<title>The gen_leader application</title>
+<title>Welcome to gen_leader</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body bgcolor="white">
-<h1>The gen_leader application</h1>
-<p><b>Version:</b> 1.0
-</p>
-<p><b>Authors:</b> Ulf Wiger (<a href="mailto:ulf.wiger@ericsson.com"><tt>ulf.wiger@ericsson.com</tt></a>), Thomas Arts (<a href="mailto:thomas.arts@ituniv.se"><tt>thomas.arts@ituniv.se</tt></a>).</p>
-A leader election behaviour modeled after gen_server.
-<p>This behaviour intends to make it reasonably
-straightforward to implement a fully distributed and fault-tolerant
-server with master-slave semantics.</p>
-
-<p>The leader election algorithm used is designed to find a leader
-in constant time. A prerequisite is that all candidates are known
-from the beginning (but obviously, they do not all need to be alive.)</p>
-
-<p>The gen_leader behaviour supports nearly everything that gen_server
-does (some functions, such as multicall() and the internal timeout,
-have been removed), and adds a few callbacks and API functions to
-support leader election etc.</p>
-
-<h2>Example</h2>
-
-<p>Included is an example program, a global dictionary,
-<a href="gdict.html">gdict</a>, based on the modules gen_leader and dict.
-The callback implementing the global dictionary is called
-'test_cb', for no particularly logical reason.</p>
-
-<h3>gdict</h3>
-
-<p><a href="gdict.html">gdict</a> consists of 50 lines of code, essentially
-emulating the interface of <code>dict.erl</code>. The "magic" in
-gdict is performed by two macros:
-<pre>
--define(store(Dict,Expr,Legend),
- gen_leader:leader_call(Dict, {store, fun(D) ->
- Expr
- end})).
-
--define(lookup(Dict, Expr, Legend),
- gen_leader:call(Dict, {lookup, fun(D) ->
- Expr
- end})).
-</pre></p>
-
-<p>(<code>Legend</code> was a means to hook in some debugging info,
-but is currently not used.)</p>
-
-<p>Using these macros, the update functions in <code>dict.erl</code>
-can be mapped to a set of gen_leader processes maintaining a
-replicated dictionary:</p>
-
-<pre>
-store(Key, Value, Dict) ->
- ?store(Dict, dict:store(Key,Value,D), store).
-
-fetch(Key, Dict) -> ?lookup(Dict, dict:fetch(Key,D), fetch).
-</pre>
-
-<p>... and so on.</p>
-
-<p>Instantiating a global dictionary is done via
-<code>gdict:new/3</code>:</p>
-
-<pre>
-new(Name, Candidates, Workers) ->
- gen_leader:start(Name,Candidates, Workers, test_cb, dict:new(), []).
-</pre>
-
-<h3>test_cb</h3>
-
-<p><a href="test_cb.html">test_cb</a> consists of 49 lines of code, and is the
-<code>gen_leader</code> callback module supporting gdict. The "magic"
-is performed by the following lines:</p>
-<pre>
-handle_leader_call({store,F}, From, Dict, E) ->
- NewDict = F(Dict),
- {reply, ok, {store, F}, NewDict};
-...
-from_leader({store,F}, Dict, E) ->
- NewDict = F(Dict),
- {ok, NewDict}.
-
-handle_call({lookup, F}, From, Dict) ->
- Reply = F(Dict),
- {reply, Reply, Dict}.
-</pre>
-
-<p>Note that updates are served through the leader, using
-<code>gen_leader:leader_call/2</code> and
-<code>handle_leader_call/4</code> respectively, while lookups
-are served locally, using <code>gen_leader:call/2</code> and
-<code>handle_call/3</code>. More details are found in <a href="test_cb.html">test_cb</a>.</p>
-
-
-<h2>Callbacks</h2>
-
-<p>Documentation of the required callbacks can be found in the
-example callback <a href="test_cb.html" target="overviewFrame">test_cb</a>.</p>
+<h1>Welcome to gen_leader</h1>
</body>
</html>
View
2 lib/gen_leader/doc/packages-frame.html
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
-<title>The gen_leader application</title>
+<title>Welcome to gen_leader</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body bgcolor="white">
View
32 lib/gen_leader/doc/test_cb.html
@@ -68,7 +68,7 @@
<h2><a name="functions">Function Details</a></h2>
<h3><a name="code_change-4">code_change/4</a></h3>
-<p><tt>code_change(FromVsn::string(), OldState::term(), E::<a href="#type-election">election()</a>, Extra::term()) -> {ok, NState} | {ok, NState, NElection}</tt>
+<p><tt>code_change(FromVsn::string(), OldState::term(), E::<a href="#type-election">election()</a>, Extra::term()) -&gt; {ok, NState} | {ok, NState, NElection}</tt>
<ul><li><tt>NState = <a href="#type-state">state()</a></tt></li><li><tt>NElection = <a href="#type-election">election()</a></tt></li></ul></p>
<p>Similar to code_change/3 in a gen_server callback module, with
the exception of the added argument E. <p>Note that is also possible
@@ -77,7 +77,7 @@
</p>
<h3><a name="elected-2">elected/2</a></h3>
-<p><tt>elected(State::<a href="#type-state">state()</a>, E::<a href="#type-election">election()</a>) -> {ok, Broadcast, NState}</tt>
+<p><tt>elected(State::<a href="#type-state">state()</a>, E::<a href="#type-election">election()</a>) -&gt; {ok, Broadcast, NState}</tt>
<ul><li><tt>Broadcast = <a href="#type-broadcast">broadcast()</a></tt></li><li><tt>NState = <a href="#type-state">state()</a></tt></li></ul></p>
<p>Called by the leader it is elected leader, and each time a
candidate recognizes the leader.
@@ -89,19 +89,19 @@
but doesn't have to be. This is up to the application.</p>
<p>Example:</p>
<pre>
- elected(Dict, E) ->
+ elected(Dict, E) -&gt;
{ok, Dict, Dict}.
</pre></p>
<h3><a name="from_leader-3">from_leader/3</a></h3>
-<p><tt>from_leader(Msg::term(), State::<a href="#type-state">state()</a>, E::<a href="#type-election">election()</a>) -> {ok, NState}</tt>
+<p><tt>from_leader(Msg::term(), State::<a href="#type-state">state()</a>, E::<a href="#type-election">election()</a>) -&gt; {ok, NState}</tt>
<ul><li><tt>NState = <a href="#type-state">state()</a></tt></li></ul></p>
<p>Called by each candidate in response to a message from the leader.
<p>In this particular module, the leader passes an update function to be
applied to the candidate's state.</p></p>
<h3><a name="handle_DOWN-3">handle_DOWN/3</a></h3>
-<p><tt>handle_DOWN(Node::<a href="#type-node">node()</a>, State::<a href="#type-state">state()</a>, E::<a href="#type-election">election()</a>) -> {ok, NState} | {ok, Broadcast, NState}</tt>
+<p><tt>handle_DOWN(Node::<a href="#type-node">node()</a>, State::<a href="#type-state">state()</a>, E::<a href="#type-election">election()</a>) -&gt; {ok, NState} | {ok, Broadcast, NState}</tt>
<ul><li><tt>Broadcast = <a href="#type-broadcast">broadcast()</a></tt></li><li><tt>NState = <a href="#type-state">state()</a></tt></li></ul></p>
<p>Called by the leader when it detects loss of a candidate node.
<p>If the function returns a <code>Broadcast</code> object, this will
@@ -109,7 +109,7 @@
<a href="#from_leader-3">from_leader/3</a>.</p></p>
<h3><a name="handle_call-3">handle_call/3</a></h3>
-<p><tt>handle_call(Request::term(), From::<a href="#type-callerRef">callerRef()</a>, State::<a href="#type-state">state()</a>) -> {reply, Reply, NState} | {noreply, <a href="#type-state">state()</a>} | {stop, Reason, Reply, NState} | <a href="#type-commonReply">commonReply()</a></tt></p>
+<p><tt>handle_call(Request::term(), From::<a href="#type-callerRef">callerRef()</a>, State::<a href="#type-state">state()</a>) -&gt; {reply, Reply, NState} | {noreply, <a href="#type-state">state()</a>} | {stop, Reason, Reply, NState} | <a href="#type-commonReply">commonReply()</a></tt></p>
<p>Equivalent to <code>Mod:handle_call/3</code> in a gen_server.
<p>Note the difference in allowed return values. <code>{ok,NState}</code>
and <code>{noreply,NState}</code> are synonymous.
@@ -119,13 +119,13 @@
<code>handle_info/2</code></p></p>
<h3><a name="handle_cast-2">handle_cast/2</a></h3>
-<p><tt>handle_cast(Msg::term(), State::<a href="#type-state">state()</a>) -> <a href="#type-commonReply">commonReply()</a></tt></p>
+<p><tt>handle_cast(Msg::term(), State::<a href="#type-state">state()</a>) -&gt; <a href="#type-commonReply">commonReply()</a></tt></p>
<p>Equivalent to <code>Mod:handle_call/3</code> in a gen_server,
except (<b>NOTE</b>) for the possible return values.
</p>
<h3><a name="handle_info-2">handle_info/2</a></h3>
-<p><tt>handle_info(Msg::term(), State::<a href="#type-state">state()</a>) -> <a href="#type-commonReply">commonReply()</a></tt></p>
+<p><tt>handle_info(Msg::term(), State::<a href="#type-state">state()</a>) -&gt; <a href="#type-commonReply">commonReply()</a></tt></p>
<p>Equivalent to <code>Mod:handle_info/3</code> in a gen_server,
except (<b>NOTE</b>) for the possible return values.
<p>This function will be called in response to any incoming message
@@ -134,7 +134,7 @@
</p>
<h3><a name="handle_leader_call-4">handle_leader_call/4</a></h3>
-<p><tt>handle_leader_call(Msg::term(), From::<a href="#type-callerRef">callerRef()</a>, State::<a href="#type-state">state()</a>, E::<a href="#type-election">election()</a>) -> {reply, Reply, NState} | {reply, Reply, Broadcast, NState} | {noreply, <a href="#type-state">state()</a>} | {stop, Reason, Reply, NState} | <a href="#type-commonReply">commonReply()</a></tt>
+<p><tt>handle_leader_call(Msg::term(), From::<a href="#type-callerRef">callerRef()</a>, State::<a href="#type-state">state()</a>, E::<a href="#type-election">election()</a>) -&gt; {reply, Reply, NState} | {reply, Reply, Broadcast, NState} | {noreply, <a href="#type-state">state()</a>} | {stop, Reason, Reply, NState} | <a href="#type-commonReply">commonReply()</a></tt>
<ul><li><tt>Broadcast = <a href="#type-broadcast">broadcast()</a></tt></li><li><tt>NState = <a href="#type-state">state()</a></tt></li></ul></p>
<p>Called by the leader in response to a
<a href="gen_leader.html#leader_call-2">leader_call()</a>.
@@ -143,10 +143,10 @@
<a href="#from_leader-3">from_leader/3</a>.</p>
<p>Example:</p>
<pre>
- handle_leader_call({store,F}, From, Dict, E) ->
+ handle_leader_call({store,F}, From, Dict, E) -&gt;
NewDict = F(Dict),
{reply, ok, {store, F}, NewDict};
- handle_leader_call({leader_lookup,F}, From, Dict, E) ->
+ handle_leader_call({leader_lookup,F}, From, Dict, E) -&gt;
Reply = F(Dict),
{reply, Reply, Dict}.
</pre>
@@ -158,18 +158,18 @@
and updates by the leader, which can lead to race conditions.</p></p>
<h3><a name="handle_leader_cast-3">handle_leader_cast/3</a></h3>
-<p><tt>handle_leader_cast(Msg::term(), State::term(), E::<a href="#type-election">election()</a>) -> <a href="#type-commonReply">commonReply()</a></tt></p>
+<p><tt>handle_leader_cast(Msg::term(), State::term(), E::<a href="#type-election">election()</a>) -&gt; <a href="#type-commonReply">commonReply()</a></tt></p>
<p>Called by the leader in response to a <a href="gen_leader.html#leader_cast-2"> leader_cast()</a>.
<p><b>BUG:</b> This has not yet been implemented.</p></p>
<h3><a name="init-1">init/1</a></h3>
-<p><tt>init(Arg::term()) -> {ok, State}</tt>
+<p><tt>init(Arg::term()) -&gt; {ok, State}</tt>
<ul><li><tt>State = <a href="#type-state">state()</a></tt></li></ul></p>
<p>Equivalent to the init/1 function in a gen_server.
</p>
<h3><a name="surrendered-3">surrendered/3</a></h3>
-<p><tt>surrendered(State::<a href="#type-state">state()</a>, Synch::<a href="#type-broadcast">broadcast()</a>, E::<a href="#type-election">election()</a>) -> {ok, NState}</tt>
+<p><tt>surrendered(State::<a href="#type-state">state()</a>, Synch::<a href="#type-broadcast">broadcast()</a>, E::<a href="#type-election">election()</a>) -&gt; {ok, NState}</tt>
<ul><li><tt>NState = <a href="#type-state">state()</a></tt></li></ul></p>
<p>Called by each candidate when it recognizes another instance as
leader.
@@ -177,12 +177,12 @@
acknowledges a leader and receives a Synch message in return.</p>
<p>Example:</p>
<pre>
- surrendered(OurDict, LeaderDict, E) ->
+ surrendered(OurDict, LeaderDict, E) -&gt;
{ok, LeaderDict}.
</pre></p>
<h3><a name="terminate-2">terminate/2</a></h3>
-<p><tt>terminate(Reason::term(), State::<a href="#type-state">state()</a>) -> Void</tt></p>
+<p><tt>terminate(Reason::term(), State::<a href="#type-state">state()</a>) -&gt; Void</tt></p>
<p>Equivalent to <code>terminate/2</code> in a gen_server callback
module.
</p>
View
2,096 lib/gen_leader/src/gen_leader.erl
1,139 additions, 957 deletions not shown because the diff is too large. Please use a local Git client to view these changes.

0 comments on commit abaf7ee

Please sign in to comment.
Something went wrong with that request. Please try again.