Ocamlnet 3 Reference Manual : Netplex_cenv.Make_lever

# Functor Netplex_cenv.Make_lever

    module Make_lever: functor (T : FUN_TYPE) -> LEVER  with type s=T.s and type r=T.r

Creates a `LEVER` module from a function type as specified in `FUN_TYPE`

Parameters: |
`T` | : | `FUN_TYPE`

    type s

argument type

    type r

result type

    type t = s -> r

    val register : Netplex_types.controller ->
           (Netplex_types.controller -> t) -> t

`let reg_lever = register ctrl raw_lever`: Registers `raw_lever` in the controller `ctrl`, so one can call `reg_lever` to activate it. For example:

               module LT = struct type s = unit type r = int end
               module L = Make_lever(LT)

               let get_num_services =
                 L.register ctrl (fun ctrl () -> List.length ctrl#services)

The registration must be done in controller context, e.g. in the `pre_start_hook` of a container.

From the running container, one can now call:

     get_num_services()

to get the current length of the `ctrl#services` list.