From: Thomas C. <cal...@gm...> - 2013-07-11 14:44:54
|
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 <in...@ge...>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 ge...@ge... > Creator of GODI and camlcity.org. > Contact details: http://www.camlcity.org/contact.html > Company homepage: http://www.gerd-stolpmann.de > ------------------------------------------------------------ > > |