<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.E-mailStijl18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=NL link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I know I can cascade the gen_server behaviour, and I’ve got it working already with the new –callback syntax. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I was wondering if there is a way to ‘import’ the init, handle_call etc callback definitions from gen_server so I don’t have to retype them in my new behaviour and, most importantly, they will keep in sync with future updates of the gen_server behaviour. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Also, what is the performance impact using the cascading approach?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks for the input,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Frans<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>Van:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Vance Shipley [mailto:vances@motivity.ca] <br><b>Verzonden:</b> vrijdag 15 augustus 2014 19:10<br><b>Aan:</b> Frans Schneider<br><b>CC:</b> Ladislav Lenart; Questions erlang-questions<br><b>Onderwerp:</b> Re: [erlang-questions] Implement standard API (was process hierarchy and passing references)<o:p></o:p></span></p></div><p class=MsoNormal><o:p> </o:p></p><p>Yes. ;)<o:p></o:p></p><div><p class=MsoNormal>On Aug 15, 2014 7:46 PM, "Frans Schneider" <<a href="mailto:schneider@xs4all.nl">schneider@xs4all.nl</a>> wrote:<o:p></o:p></p><p class=MsoNormal>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/wiki/index.php?title=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:<o:p></o:p></p><p class=MsoNormal>Hello.<br><br><br>On 15.8.2014 11:49, Frans Schneider wrote:<o:p></o:p></p><p class=MsoNormal>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.<o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>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><o:p></o:p></p><p class=MsoNormal>Thanks<br><br>Frans<br><br><br>On 08/14/2014 05:16 PM, Ladislav Lenart wrote:<o:p></o:p></p><p class=MsoNormal>Hello again.<br><br><br>On 14.8.2014 17:00, Ladislav Lenart wrote:<o:p></o:p></p><p class=MsoNormal>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.<o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>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/supervisor.html</a><o:p></o:p></p><p class=MsoNormal>* Pass supervisor's PID to its children.<br>* Each worker process can lookup PID of its relevant sibling via<br>supervisor:which_children/1.<o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>HTH,<br><br>Ladislav Lenart<br><br><o:p></o:p></p><p class=MsoNormal>On 14.8.2014 16:48, Schneider wrote:<o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>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>_______________________________________________<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/listinfo/erlang-questions</a><o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>_______________________________________________<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/listinfo/erlang-questions</a><o:p></o:p></p><p class=MsoNormal>_______________________________________________<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/listinfo/erlang-questions</a><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><br>_______________________________________________<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/listinfo/erlang-questions</a><o:p></o:p></p></div></div></body></html>