<div dir="ltr">Even if in this case I would not use inheritance, I think you should check mixer: <a href="https://github.com/opscode/mixer">https://github.com/opscode/mixer</a>. It let's you use mixins, aka do not type the same code for two different modules that share some functionality (cowboy endpoints for example).<div>
<br></div><div>Regards,</div><div>Federico.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Aug 15, 2014 at 6:49 AM, Frans Schneider <span dir="ltr"><<a href="mailto:schneider@xs4all.nl" target="_blank">schneider@xs4all.nl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi list,<br>
<br>
Now that I got the supervision working, I am looking for a way to implement a standard API for every "main" server. The API implements a way for the main gen_server to call the RPC middleman and should also define standard callbacks for the main server the middleman can use. The API would also use some internal state. In a previous life, I would have used inheritance to accomplish this, but how can I do this in Erlang?<br>
I had a look at the supervisor implementation, but was wondering if there is a easier way to accomplish this.<br>
<br>
Thanks<br>
<br>
Frans<br>
<br>
<br>
On 08/14/2014 05:16 PM, Ladislav Lenart wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello again.<br>
<br>
<br>
On 14.8.2014 17:00, Ladislav Lenart wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello.<br>
<br>
What about the following solution:<br>
* Put all three processes under one supervisor.<br>
* Set its restart strategy to one_for_all.<br>
</blockquote>
Or rest_for_one. This one may better suite your needs. For more info, refer to<br>
the official documentation at: <a href="http://www.erlang.org/doc/man/supervisor.html" target="_blank">http://www.erlang.org/doc/man/<u></u>supervisor.html</a><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
* Pass supervisor's PID to its children.<br>
* Each worker process can lookup PID of its relevant sibling via<br>
supervisor:which_children/1.<br>
</blockquote>
<br>
HTH,<br>
<br>
Ladislav Lenart<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 14.8.2014 16:48, Schneider wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi list,<br>
<br>
Since I am very new to Erlang, I am not sure how to layout process<br>
hierarchies in the following case:<br>
<br>
Besides the domain specific functionality, every program has a RPC<br>
middleman and an XML-RPC interface, each implemented as gen_servers. In<br>
the current setup, the main gen_server process starts the RPC middleman,<br>
passing it its Pid, and the RPC gen_server starts the XML-RPC server<br>
which is passed the RPC middleman's Pid.<br>
Using the passed in Pid's, the XML-RPC server can do a<br>
gen_server:call()/cast() back to the RPC server which on its turn can<br>
call the main server. Works ok, but I would like to have the RPC<br>
middleman and XML-RPC controller under the control of a supervisor. The<br>
main supervisor should start the main gen_server process plus a<br>
supervisor that on its turn should start the RPC midleman and the<br>
XML-RPC handler.<br>
The thing I can't figure out is how the XML-RPC process should find the<br>
RPC middleman process and how that process should locate the main server<br>
when using supervision. Since there can be many RPC middlemen and<br>
XMP-RPC servers around, each belonging to different main servers, naming<br>
and registering seems a little hard.<br>
So how to pass references around?<br>
<br>
Any help will be very much appreciated.<br>
<br>
Frans<br>
______________________________<u></u>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a><br>
<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a><br>
<br>
</blockquote>
<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><a href="http://federicocarrone.com/" target="_blank">http://federicocarrone.com/</a><br></div>
</div>