<p dir="ltr">Yes. ;)</p>
<div class="gmail_quote">On Aug 15, 2014 7:46 PM, "Frans Schneider" <<a href="mailto:schneider@xs4all.nl">schneider@xs4all.nl</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Yes, I guess defining my own behaviour is what I am looking for.<br>
Found Cascading Behaviours (<a href="http://erlangcentral.org/wiki/index.php?title=Cascading_Behaviours" target="_blank">http://erlangcentral.org/<u></u>wiki/index.php?title=<u></u>Cascading_Behaviours</a>) which seems to do the trick.<br>

It is a little dated and still uses behaviour_info(). Is it possible to reuse the callback definitions from gen_server?<br>
<br>
Frans<br>
<br>
<br>
On 08/15/2014 04:02 PM, 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>
<br>
On 15.8.2014 11:49, Frans 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>
Now that I got the supervision working, I am looking for a way to<br>
implement a standard API for every "main" server. The API implements a<br>
way for the main gen_server to call the RPC middleman and should also<br>
define standard callbacks for the main server the middleman can use. The<br>
API would also use some internal state. In a previous life, I would have<br>
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<br>
there is a easier way to accomplish this.<br>
</blockquote>
I am not sure I follow you completely. However, if you want to parametrize<br>
process behavior in Erlang (i.e. something similar to OO inheritance that you<br>
mentioned), you can define your own behaviour (a module) and define different<br>
callback modules that all implement it. The pattern is the same as with a<br>
gen_server behaviour.<br>
<br>
If this is not what you need, please provide us with a concrete example(s) that<br>
you currently struggle with.<br>
<br>
<br>
HTH,<br>
Ladislav Lenart<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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>
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>
______________________________<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></blockquote>
______________________________<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>
<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>