Getting configuration variables within hooks in Netplex

Thomas Calderon <[email protected]> Thu, 11 Jul 2013 16:14:44 +0200
Newsgroups gmane.comp.lang.ocaml.lib.net.devel
Message-ID <CA+1ewKY1GvExpaD+L1Z7d-EGv=AZetuVTZASLZY6mML2LaOiYg@mail.gmail.com>
--===============3721257767963029563==
Content-Type: multipart/alternative; boundary=90e6ba6152344abe8704e13d05ba

--90e6ba6152344abe8704e13d05ba
Content-Type: text/plain; charset=UTF-8

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

--90e6ba6152344abe8704e13d05ba
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi there,<br><div class=3D"gmail_quote"><div dir=3D"ltr"><=
div><br></div><div>I would like to know if it is possible retrieve configur=
ation parameters from a hook.</div><div>I get that the variable goes down f=
rom the configure and setup functions. However I would like to make the var=
iable accessible from the hook (see example below).</div>


<div><br></div><div>Example below:</div><div><br></div><div>...</div><div>l=
et setup srv my_variable =3D=C2=A0</div><div>=C2=A0 ...</div><div>=C2=A0 (r=
egister some rpc)</div><div>=C2=A0 ...</div><div>
=C2=A0 my_variable</div><div><br></div><div><br></div><div><div>let configu=
re cf addr =3D</div><div>=C2=A0 let my_variable =3D</div><div>=C2=A0 =C2=A0=
 try</div><div>=C2=A0 =C2=A0 =C2=A0 cf # string_param (cf # resolve_paramet=
er addr &quot;my_variable&quot;)</div>


<div>=C2=A0 =C2=A0 with</div><div>=C2=A0 =C2=A0 =C2=A0 | Not_found -&gt;</d=
iv><div>=C2=A0 =C2=A0 =C2=A0 failwith &quot;Required parameter my_variable =
is missing!&quot; in</div><div>=C2=A0 my_variable</div><div>;;</div><div><b=
r></div></div><div><div>let rpc_my_factory =3D</div>


<div>=C2=A0 Rpc_netplex.rpc_factory</div><div>=C2=A0 =C2=A0 ~configure</div=
><div>=C2=A0 =C2=A0 ~name:&quot;my_rpc&quot;</div><div>=C2=A0 =C2=A0 ~setup=
</div><div>=C2=A0 =C2=A0 ~hooks:(fun _ -&gt;</div><div>=C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 object(self)</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 inherit N=
etplex_kit.empty_processor_hooks()</div>


<div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 method post_start_hook _ =3D</div><div>=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></div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (=
)</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 end</div><div>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0)</div><div>=C2=A0 =C2=A0 ()</div>


</div></div>
</div><br></div>

--90e6ba6152344abe8704e13d05ba--


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

--===============3721257767963029563==--