Created
November 13, 2014 13:53
-
-
Save rlipscombe/6824460d204adce433ca to your computer and use it in GitHub Desktop.
Boilerplate gen_server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(example_server). | |
-export([start_link/0, start/0]). | |
-behaviour(gen_server). | |
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). | |
start_link() -> | |
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). | |
start() -> | |
gen_server:start({local, ?MODULE}, ?MODULE, [], []). | |
init([]) -> | |
State = undefined, | |
{ok, State}. | |
handle_call(_Req, _From, State) -> | |
{reply, ok, State}. | |
handle_cast(_Req, State) -> | |
{noreply, State}. | |
handle_info(_Info, State) -> | |
{noreply, State}. | |
terminate(_Reason, _State) -> | |
ok. | |
code_change(_OldVsn, State, _Extra) -> | |
{ok, State}. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment