Re: Getting configuration variables within hooks in Netplex
Thomas Calderon <[email protected]> Thu, 11 Jul 2013 16:44:27 +0200
| Newsgroups | gmane.comp.lang.ocaml.lib.net.devel |
|---|---|
| Message-ID | <CA+1ewKaMpbocErDEja1-GoD329zewHqivcUKjjbQJCssTkPjoQ@mail.gmail.com> |
--===============4102892933704723015== Content-Type: multipart/alternative; boundary=90e6ba61523493a30f04e13d6f01 --90e6ba61523493a30f04e13d6f01 Content-Type: text/plain; charset=UTF-8 Hi, Thanks for the reply. I had tried something like that, but somehow I missed it. Cheers. Thomas. On Thu, Jul 11, 2013 at 4:38 PM, Gerd Stolpmann <[email protected]>wrote: > Am Donnerstag, den 11.07.2013, 16:14 +0200 schrieb Thomas Calderon: > > Hi there, > > > > > > I would like to know if it is possible retrieve configuration parameters > from a hook. > > I get that the variable goes down from the configure and setup > functions. However I would like to make the variable accessible from the > hook (see example below). > > > > > > Example below: > > > > > > ... > > let setup srv my_variable = > > ... > > (register some rpc) > > ... > > my_variable > > > > > > > > > > let configure cf addr = > > let my_variable = > > try > > cf # string_param (cf # resolve_parameter addr "my_variable") > > with > > | Not_found -> > > failwith "Required parameter my_variable is missing!" in > > my_variable > > ;; > > > > > > let rpc_my_factory = > > Rpc_netplex.rpc_factory > > ~configure > > ~name:"my_rpc" > > ~setup > > ~hooks:(fun _ -> > > object(self) > > inherit Netplex_kit.empty_processor_hooks() > > method post_start_hook _ = > > Do_Something my_variable; (* > here *) > > > > () > > end > > ) > > () > > Yes, this is possible: the output of ~configure is the input of ~hooks: > > let rpc_my_factory = > Rpc_netplex.rpc_factory > ~configure > ~name:"my_rpc" > ~setup > ~hooks:(fun my_variable -> (* look here *) > object(self) > inherit Netplex_kit.empty_processor_hooks() > method post_start_hook _ = > Do_Something my_variable; > () > end > ) > () > > > Gerd > > -- > ------------------------------------------------------------ > Gerd Stolpmann, Darmstadt, Germany [email protected] > Creator of GODI and camlcity.org. > Contact details: http://www.camlcity.org/contact.html > Company homepage: http://www.gerd-stolpmann.de > ------------------------------------------------------------ > > --90e6ba61523493a30f04e13d6f01 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Hi,<div><br></div><div style>Thanks for the reply. I had t= ried something like that, but somehow I missed it.</div><div style><br></di= v><div style>Cheers.</div><div style><br></div><div style>Thomas.</div></di= v> <div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On Thu, Jul 1= 1, 2013 at 4:38 PM, Gerd Stolpmann <span dir=3D"ltr"><<a href=3D"mailto:= [email protected]" target=3D"_blank">[email protected]</a>></s= pan> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex">Am Donnerstag, den 11.07.2013, 16:14 +0200 s= chrieb Thomas Calderon:<br> <div><div class=3D"h5">> Hi there,<br> ><br> ><br> > I would like to know if it is possible retrieve configuration paramete= rs from a hook.<br> > I get that the variable goes down from the configure and setup functio= ns. However I would like to make the variable accessible from the hook (see= example below).<br> ><br> ><br> > Example below:<br> ><br> ><br> > ...<br> > let setup srv my_variable =3D<br> > =C2=A0 ...<br> > =C2=A0 (register some rpc)<br> > =C2=A0 ...<br> > =C2=A0 my_variable<br> ><br> ><br> ><br> ><br> > let configure cf addr =3D<br> > =C2=A0 let my_variable =3D<br> > =C2=A0 =C2=A0 try<br> > =C2=A0 =C2=A0 =C2=A0 cf # string_param (cf # resolve_parameter addr &q= uot;my_variable")<br> > =C2=A0 =C2=A0 with<br> > =C2=A0 =C2=A0 =C2=A0 | Not_found -><br> > =C2=A0 =C2=A0 =C2=A0 failwith "Required parameter my_variable is = missing!" in<br> > =C2=A0 my_variable<br> > ;;<br> ><br> ><br> > let rpc_my_factory =3D<br> > =C2=A0 Rpc_netplex.rpc_factory<br> > =C2=A0 =C2=A0 ~configure<br> > =C2=A0 =C2=A0 ~name:"my_rpc"<br> > =C2=A0 =C2=A0 ~setup<br> > =C2=A0 =C2=A0 ~hooks:(fun _ -><br> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 object(self)<br> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 inherit Netplex_kit.empty_processor_hooks(= )<br> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 method post_start_hook _ =3D<br> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Do_Something my_variable; =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 (* here *)<br> ><br> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ()<br> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 end<br> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0)<br> > =C2=A0 =C2=A0 ()<br> <br> </div></div>Yes, this is possible: the output of ~configure is the input of= ~hooks:<br> <div class=3D"im"><br> let rpc_my_factory =3D<br> =C2=A0 Rpc_netplex.rpc_factory<br> =C2=A0 =C2=A0 ~configure<br> =C2=A0 =C2=A0 ~name:"my_rpc"<br> =C2=A0 =C2=A0 ~setup<br> </div>=C2=A0 =C2=A0 ~hooks:(fun my_variable -> =C2=A0 =C2=A0(* look here= *)<br> <div class=3D"im">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 object(self)<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 inherit Netplex_kit.empty_process= or_hooks()<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 method post_start_hook _ =3D<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Do_Something my_variable;<= br> </div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ()<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 end<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0)<br> =C2=A0 =C2=A0 ()<br> <span class=3D"HOEnZb"><font color=3D"#888888"><br> <br> Gerd<br> <br> --<br> ------------------------------------------------------------<br> Gerd Stolpmann, Darmstadt, Germany =C2=A0 =C2=A0<a href=3D"mailto:gerd@gerd= -stolpmann.de">[email protected]</a><br> Creator of GODI and <a href=3D"http://camlcity.org" target=3D"_blank">camlc= ity.org</a>.<br> Contact details: =C2=A0 =C2=A0 =C2=A0 =C2=A0<a href=3D"http://www.camlcity.= org/contact.html" target=3D"_blank">http://www.camlcity.org/contact.html</a= ><br> Company homepage: =C2=A0 =C2=A0 =C2=A0 <a href=3D"http://www.gerd-stolpmann= .de" target=3D"_blank">http://www.gerd-stolpmann.de</a><br> ------------------------------------------------------------<br> <br> </font></span></blockquote></div><br></div> --90e6ba61523493a30f04e13d6f01-- --===============4102892933704723015== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ See everything from the browser to the database with AppDynamics Get end-to-end visibility with application monitoring from AppDynamics Isolate bottlenecks and diagnose root cause in seconds. Start your free trial of AppDynamics Pro today! http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk --===============4102892933704723015== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Ocamlnet-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ocamlnet-devel --===============4102892933704723015==--