Re: Getting configuration variables within hooks in Netplex

Gerd Stolpmann <[email protected]> Thu, 11 Jul 2013 16:38:11 +0200
Newsgroups gmane.comp.lang.ocaml.lib.net.devel
Message-ID <1373553491.30825.24.camel@thinkpad>
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
------------------------------------------------------------


------------------------------------------------------------------------------
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