[erlang-questions] Supervision Tree

Bengt Kleberg <>
Wed Nov 28 13:42:55 CET 2012


Greetings,

Yes, I use 2 modules. One for the interface and one for the call back
functions. Actually, make that 2 or 3. If the 2 modules need to share
functions I do not want to have a circular dependency.


bengt

On Wed, 2012-11-28 at 07:23 -0500, Fred Hebert wrote:
> I'm not sure I'm understanding you right. Do you advocate never wrapping
> function calls to special processes (i.e. all OTP behaviours) in a
> functional interface, and basically just letting people use whatever to
> call them?
> 
> I don't know why, but I'm somewhat cringing at the idea of code that
> makes things like the registration it uses (local, global, via), stats
> logging calls, any modification it wraps around the data, and so on, a
> burden on all the callers rather than keeping it unique in one place.
> 
> Not using wrapper functions makes it harder to test (and mock), change
> the interface or implementation (supervisor -> supervisor_bridge, or
> using a protected ETS table for quick reads rather than messaging the
> process), document (no EDoc goes there), and type check (no restrictive
> type specs possible to declare).
> 
> Maybe you instead meant that you would have something like
> 'myapp_serv.erl' only doing raw gen_server callbacks, and then another
> module 'myapp_api' that does the wrapping, in which case that sounds
> much better as a compromise and wouldn't have me frothing at the mouth
> if I ended up maintaining that code base (in which case, disregard the
> two paragraphs before this one) :)
> 
> Regards,
> Fred.
> 
> On 11/28, Bengt Kleberg wrote:
> > Greetings,
> > 
> > First let me mention that I prefer to never mix call back code that runs
> > in a special process (in this case the supervision process) with code
> > used by other processes. So, start_link/0 is better off in another
> > module.
> > 
> > Secondly, if you have a variable with _ first in the name the compiler
> > should not complain about it not being used. What is your compile
> > command?
> > 
> > Last, _Args is the [] from supervisor:start_link/2
> > 
> > 
> > ebngt
> > 
> > On Wed, 2012-11-28 at 12:23 +0200, Lucky Khoza wrote:
> > > Hi Erlang Developers,
> > > 
> > > I'm actually trying to understand and compile the following module
> > > code, and i don't understand why the init/1 function takes an argument
> > > which it doesn't use at all, so when i try to compile the module it
> > > complains about the argument _Args because it's unused.
> > > 
> > > May someone help me understand the use of this argument?
> > > 
> > > -module(ch_sup).
> > > -behaviour(supervisor).
> > > 
> > > -export([start_link/0]).
> > > -export([init/1]).
> > > 
> > > start_link() ->
> > >     supervisor:start_link(ch_sup, []).
> > > 
> > > init(_Args) ->
> > >     {ok, {{one_for_one, 1, 60},
> > >           [{ch3, {ch3, start_link, []},
> > >             permanent, brutal_kill, worker, [ch3]}]}}.
> > > 
> > > 
> > > Thanks for a lot for your help, i really appreciate it.
> > > Kindest Regards
> > > Lucky
> > > _______________________________________________
> > > erlang-questions mailing list
> > > 
> > > http://erlang.org/mailman/listinfo/erlang-questions
> > 
> > _______________________________________________
> > erlang-questions mailing list
> > 
> > http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list