<div dir="ltr"><div>Hi Gerald,<br><br></div>You don't really need all that OTP stuff for the use case you have. You can use them, but it would be a bit artificial. Attached is a module I use for load testing of ibrowse - hopefully it will give you some ideas.<br><br>regards,<br>Chandru<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 5 November 2014 14:30, Gerald Weber <span dir="ltr"><<a href="mailto:gerald.weber@besharp.at" target="_blank">gerald.weber@besharp.at</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div link="#0563C1" vlink="#954F72" lang="DE-AT"><div><p class="MsoNormal">Hi Coders,<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">finally i have a first real world project to support my efforts in learning erlang and OTP:<u></u><u></u></p><p class="MsoNormal">Trying to write an application to load-test a Java backend. This java daemon talks json over HTTP (jetty).<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">The backend requires a login (GET request, no HTTP Authentication), some register stuff for subscriptions<u></u><u></u></p><p class="MsoNormal">and finally a loop to receive all of the events (the step waiting for events is blocking)<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">So my vision is:<u></u><u></u></p><p class="MsoNormal">- 1x application<u></u><u></u></p><p class="MsoNormal">-- 1x supervisor<u></u><u></u></p><p class="MsoNormal">--- 1x (?) gen_server<u></u><u></u></p><p class="MsoNormal">---- n x Y<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">The gen_server should wait for a msg like {start_workers,50} and should then start 50 instances of Y<u></u><u></u></p><p class="MsoNormal">connecting to the java backend, run some httpc:request calls and receive the return values (which is json)<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I have really no clear idea which OTP principle can be used for Y, maybe my mindset tells me gen_server is a process to "serve data"<u></u><u></u></p><p class="MsoNormal">and not to ask for data. What would be the best bet ?<u></u><u></u></p><p class="MsoNormal">Or is my simple understanding that Y screams for an gen_fsm including the httpc calls not that wrong ?<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Can the supervisor be told to start x instances of Y on request ?<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">thx and sorry for my maybe too easy questions.<span class="HOEnZb"><font color="#888888"><u></u><u></u></font></span></p><span class="HOEnZb"><font color="#888888"><p class="MsoNormal">gerald<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p></font></span></div></div><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></blockquote></div><br></div>