<div dir="ltr"><a href="http://learnyousomeerlang.com/supervisors">http://learnyousomeerlang.com/supervisors</a><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 15 October 2014 16:32, Curtis J Schofield (ram9) <span dir="ltr"><<a href="mailto:curtis@ram9.cc" target="_blank">curtis@ram9.cc</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thank you Vance. That does indeed work - I think I want 'permanent' so<br>
that the worker comes back if the application crashes - is it as<br>
simple as that?<br>
<br>
My question about ChildSpec is about 'Module' and the erlang docs.<br>
<br>
>From the erlang docs:<br>
"Modules is used by the release handler during code replacement to<br>
determine which processes are using a certain module. As a rule of<br>
thumb Modules should be a list with one element [Module], where Module<br>
is the callback module, if the child process is a supervisor,<br>
gen_server or gen_fsm."<br>
<br>
My 'sender_worker' is just a module - it is not a supervisor,<br>
gen_server or gen_fsm. Is there some specific interface that the<br>
module function 'boot_send' needs to conform to - or is returning {ok,<br>
Pid} what it needs to do?<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On Tue, Oct 14, 2014 at 9:34 PM, Vance Shipley <<a href="mailto:vances@motivity.ca">vances@motivity.ca</a>> wrote:<br>
><br>
> On Wed, Oct 15, 2014 at 5:50 AM, Curtis J Schofield (ram9) <curtis@ram9.cc><br>
> wrote:<br>
>><br>
>> I have been able to create a simple application with a supervisor and<br>
>> spawn<br>
>> and link a child process. I feel like I have 'hacked' it and would<br>
>> like to hear what the ideomatic way of this is.<br>
>><br>
>      init([]) -><br>
>          {ok, Pid} = sender_worker:boot_send(),<br>
>          link(Pid),<br>
>          Pids = [],<br>
>          {ok, {{one_for_one, 1, 5}, Pids}}.<br>
><br>
> The supervisor behaviour encapsulates process creation and linking.  All you<br>
> need to do is specify the process to create in a child specification:<br>
><br>
>      {Id, StartFunc, Restart, Shutdown, Type, Modules}<br>
><br>
> So just:<br>
><br>
>      init([]) -><br>
>           StartMod = sender_worker,<br>
>           ChildSpec = {StartMod, {StartMod, boot_send, []}, temporary, 4,<br>
> worker, [StartMod]},<br>
>           {ok, {{one_for_one, 1, 5}, [ChildSpec]}}.<br>
><br>
> --<br>
>      -Vance<br>
><br>
> On Wed, Oct 15, 2014 at 5:50 AM, Curtis J Schofield (ram9) <curtis@ram9.cc><br>
> wrote:<br>
>><br>
>> Hi - I'm a beginner and am requesting feedback on some code I wrote.<br>
>><br>
>> I haven't  been able to deduce 'the otp way' to build a worker process.<br>
>>  ( this worker generates some garbage and puts it into rabbitmq)<br>
>><br>
>> I have been able to create a simple application with a supervisor and<br>
>> spawn<br>
>> and link a child process. I feel like I have 'hacked' it and would<br>
>> like to hear what the ideomatic way of this is.<br>
>><br>
>><br>
>><br>
>> <a href="https://github.com/robotarmy/amqresearch/blob/master/send/src/sender_sup.erl" target="_blank">https://github.com/robotarmy/amqresearch/blob/master/send/src/sender_sup.erl</a><br>
>><br>
>><br>
>> <a href="https://github.com/robotarmy/amqresearch/blob/master/send/src/sender_worker.erl" target="_blank">https://github.com/robotarmy/amqresearch/blob/master/send/src/sender_worker.erl</a><br>
>><br>
>><br>
>> Feedback on my code would be appreciated.<br>
>><br>
>><br>
>> --<br>
>> ---<br>
>> Modern Yoga vs Traditional Yoga<br>
>> <a href="http://swamij.com/traditional-yoga.htm#swamirama" target="_blank">http://swamij.com/traditional-yoga.htm#swamirama</a><br>
>> _______________________________________________<br>
>> erlang-questions mailing list<br>
>> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
>> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
><br>
><br>
><br>
><br>
> --<br>
> --<br>
>      -Vance<br>
<br>
<br>
<br>
--<br>
---<br>
Modern Yoga vs Traditional Yoga<br>
<a href="http://swamij.com/traditional-yoga.htm#swamirama" target="_blank">http://swamij.com/traditional-yoga.htm#swamirama</a><br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br></div>