Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 79 lines (64 sloc) 1.895 kb
277ceff @mbbx6spp Template for Finsignia compliant gen_server.
authored
1 %%%' HEADER
454c732 @mbbx6spp Fix template variable typo in finsrv
authored
2 %%% @author {{author_name}} <{{author_email}}>
277ceff @mbbx6spp Template for Finsignia compliant gen_server.
authored
3 %%% @copyright {{copyright_year}} {{author_name}}
4 %%% @doc gen_server callback module implementation:
5 %%% {{description}}
6 %%% @end
7 -module({{name}}_srv).
8 -author('{{author_name}} <{{author_email}}>').
9
10 -behaviour(gen_server).
11
12 -export([start_link/0]).
13 -export([init/1, handle_call/3, handle_cast/2, handle_info/2]).
14 -export([code_change/3]).
15 -export([stop/0, terminate/2]).
16
17 % TODO: If unnamed server, remove definition below.
18 -define(SERVER, ?MODULE).
19 %%%.
20 %%%' PUBLIC API
21
22 %% @doc starts gen_server implementation and caller links to the process too.
fa3168e @mbbx6spp Clean up finsrv template for gen_server modules
authored
23 -spec start_link() -> {ok, Pid} | ignore | {error, Error}
24 when
25 Pid :: pid(),
26 Error :: {already_started, Pid} | term().
277ceff @mbbx6spp Template for Finsignia compliant gen_server.
authored
27 start_link() ->
28 % TODO: decide whether to name gen_server callback implementation or not.
29 % gen_server:start_link(?MODULE, [], []). % for unnamed gen_server
30 gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
31
709c8b2 @mbbx6spp gen_server callback stop/1 moved to API section.
authored
32 %% @doc stops gen_server implementation process
fa3168e @mbbx6spp Clean up finsrv template for gen_server modules
authored
33 -spec stop() -> ok.
709c8b2 @mbbx6spp gen_server callback stop/1 moved to API section.
authored
34 stop() ->
be024ce @mbbx6spp Bugs now fixed in finsrv Rebar template.
authored
35 gen_server:cast(?SERVER, stop).
709c8b2 @mbbx6spp gen_server callback stop/1 moved to API section.
authored
36
277ceff @mbbx6spp Template for Finsignia compliant gen_server.
authored
37 % TODO: add more public API here...
38
39 %%%.
40 %%%' CALLBACKS
fa3168e @mbbx6spp Clean up finsrv template for gen_server modules
authored
41 %% @callback gen_server
277ceff @mbbx6spp Template for Finsignia compliant gen_server.
authored
42 init(State) ->
43 {ok, State}.
44
fa3168e @mbbx6spp Clean up finsrv template for gen_server modules
authored
45 %% @callback gen_server
277ceff @mbbx6spp Template for Finsignia compliant gen_server.
authored
46 handle_call(_Req, _From, State) ->
47 {reply, State}.
48
fa3168e @mbbx6spp Clean up finsrv template for gen_server modules
authored
49 %% @callback gen_server
277ceff @mbbx6spp Template for Finsignia compliant gen_server.
authored
50 handle_cast(stop, State) ->
51 {stop, normal, State};
52 handle_cast(_Req, State) ->
53 {noreply, State}.
54
fa3168e @mbbx6spp Clean up finsrv template for gen_server modules
authored
55 %% @callback gen_server
277ceff @mbbx6spp Template for Finsignia compliant gen_server.
authored
56 handle_info(_Info, State) ->
57 {noreply, State}.
58
fa3168e @mbbx6spp Clean up finsrv template for gen_server modules
authored
59 %% @callback gen_server
277ceff @mbbx6spp Template for Finsignia compliant gen_server.
authored
60 code_change(_OldVsn, State, _Extra) ->
61 {ok, State}.
62
fa3168e @mbbx6spp Clean up finsrv template for gen_server modules
authored
63 %% @callback gen_server
277ceff @mbbx6spp Template for Finsignia compliant gen_server.
authored
64 terminate(normal, _State) ->
65 ok;
66 terminate(shutdown, _State) ->
67 ok;
68 terminate({shutdown, _Reason}, _State) ->
69 ok;
be024ce @mbbx6spp Bugs now fixed in finsrv Rebar template.
authored
70 terminate(_Reason, _State) ->
277ceff @mbbx6spp Template for Finsignia compliant gen_server.
authored
71 ok.
72
73 %%%.
74 %%%' PRIVATE FUNCTIONS
75 % TODO: Add private helper functions here.
76
77 %%%.
78 %%% vim: set filetype=erlang tabstop=2 foldmarker=%%%',%%%. foldmethod=marker:
Something went wrong with that request. Please try again.