Created
January 1, 2015 00:43
-
-
Save evanmcc/a25324d547fe332960ab to your computer and use it in GitHub Desktop.
tempo template for lighter gen_server + with lager integration
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
(tempo-define-template "gen-server" | |
'((erlang-skel-include erlang-skel-small-header) | |
"-behaviour(gen_server)." n n | |
"%% API" n | |
"-export([start_link/0])." n n | |
"%% gen_server callbacks" n | |
"-export([init/1, handle_call/3, handle_cast/2, " | |
"handle_info/2," n> | |
"terminate/2, code_change/3])." n n | |
"-define(SERVER, ?MODULE)." n n | |
"-record(state, {})." n n | |
(erlang-skel-double-separator-start 3) | |
"%%% API" n | |
(erlang-skel-double-separator-end 3) n | |
"start_link() ->" n> | |
"gen_server:start_link({local, ?SERVER}, ?MODULE, [], [])." n | |
n | |
(erlang-skel-double-separator-start 3) | |
"%%% gen_server callbacks" n | |
(erlang-skel-double-separator-end 3) | |
n | |
"init([]) ->" n> | |
"{ok, #state{}}." n | |
n | |
"handle_call(_Request, _From, State) ->" n> | |
"lager:warning(\"~p ~p got unexpected call ~p from ~p\"," n> | |
"[?MODULE, self(), _Request, _From])," n> | |
"Reply = ok," n> | |
"{reply, Reply, State}." n | |
n | |
"handle_cast(_Msg, State) ->" n> | |
"lager:warning(\"~p ~p got unexpected cast ~p\"," n> | |
"[?MODULE, self(), _Msg])," n> | |
"{noreply, State}." n | |
n | |
"handle_info(_Info, State) ->" n> | |
"lager:warning(\"~p ~p got unexpected message ~p\"," n> | |
"[?MODULE, self(), _Info])," n> | |
"{noreply, State}." n | |
n | |
"terminate(_Reason, _State) ->" n> | |
"ok." n | |
n | |
"code_change(_OldVsn, State, _Extra) ->" n> | |
"{ok, State}." n | |
n | |
(erlang-skel-double-separator-start 3) | |
"%%% Internal functions" n | |
(erlang-skel-double-separator-end 3) | |
) | |
"*The template of a generic server. | |
Please see the function `tempo-define-template'.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment