Skip to content

Instantly share code, notes, and snippets.

@vladimir-vg
Created July 8, 2017 19:28
Show Gist options
  • Save vladimir-vg/961a21ee2b2ca67d9aee1dca1a6efc03 to your computer and use it in GitHub Desktop.
Save vladimir-vg/961a21ee2b2ca67d9aee1dca1a6efc03 to your computer and use it in GitHub Desktop.
espace demo 07-2017 erl modules
-module(morpheus_sup).
-behaviour(supervisor).
-export([start_link/0]).
-export([init/1]).
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
init([]) ->
SupOpts = #{strategy => one_for_one, intensity => 5, period => 1},
Children = [
#{id => neo_worker, start => {neo, start_link, []}}
],
{ok, {SupOpts, Children}}.
-module(neo).
-behaviour(gen_server).
-export([start_link/0]).
-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, [], []).
init([]) ->
{ok, no_state}.
handle_info(Msg, State) ->
{stop, {unknown_message, Msg}, State}.
handle_call(find_smith, _From, State) ->
{reply, {found, hinding_under_the_table}, State};
handle_call(Call, _From, State) ->
{stop, {unknown_call, Call}, State}.
handle_cast(Cast, State) ->
{stop, {unknown_cast, Cast}, State}.
code_change(_, State, _) -> {ok, State}.
terminate(_,_State) -> ok.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment