Skip to content

Instantly share code, notes, and snippets.

@hukl
Created August 5, 2015 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hukl/baa2511fa73212741bc6 to your computer and use it in GitHub Desktop.
Save hukl/baa2511fa73212741bc6 to your computer and use it in GitHub Desktop.
-module().
-behavior(gen_server).
% Managment API
-export([start/0, start_link/0, stop/0]).
% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2,
code_change/3]).
% Public API
-export([]).
% Example state record
% -record(state, { data = {} }).
%% ===================================================================
%% Management API
%% ===================================================================
start() ->
gen_server:start({local, ?MODULE}, ?MODULE, [], []).
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
stop() -> gen_server:cast(?MODULE, stop).
%% ===================================================================
%% gen_server callbacks
%% ===================================================================
init([]) ->
{ok, {}}.
handle_call(_Msg, _From, State) ->
{reply, ok, State}.
handle_cast(stop, State) ->
{stop, normal, State};
handle_cast(_Msg, State) ->
{stop, normal, State}.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
handle_info(_Info, State) ->
{noreply, State}.
terminate(_Reason, _State) ->
whatever.
%% ===================================================================
%% Public API
%% ===================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment