Skip to content
This repository
tag: v1698
Fetching contributors…

Cannot retrieve contributors at this time

file 111 lines (91 sloc) 3.097 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
(*
Copyright © 2011 MLstate

This file is part of OPA.

OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.

OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.

You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)

(**
Module type COMPONENT accepted by the Runtime layer.
Runtime merge several COMPONENT in one APPLICATION.
@author Cedric Soulas
*)

module type COMPONENT =
sig
  type options
  type t

  val name : string
  val version : string

  val default_options : options
    (** Default options *)

  val spec_args : string -> (options ServerArg.arg_parser) list
   (**
[spec_args name] return the command line parser specification for type options.
The name can be used to prefix the command line to avoid
command line conflicts when adding several identical component.
Example: [HttpServerOptions.spec_args].
*)

  val make : string -> options -> Scheduler.t -> t
    (**
[make name opt sched] make a named component of type [t]
from a set of options [opt].
See [run].
*)

  val get_ports : t -> Scheduler.t -> RuntimeType.Ports.t
    (**
Return the list of ports needed by the component.
See [RuntimeType.Ports].
*)

  val get_description : t -> Scheduler.t -> RuntimeType.Description.t
    (**
Return the description of the component, to be used as
a port by another component.
See [RuntimeType.Description]
*)

  val run : t -> Scheduler.t -> t
    (**
Run the component of type [t].
This function is called when all components have been made
via their [make] function.
*)

  val close : t -> Scheduler.t -> unit
    (**
Close the component.
This function is called at the end of the program.
*)
end

(**
Module type APPLICATION produced by the Runtime layer from a set of COMPONENT.
*)
module type APPLICATION =
sig
  type options
  type t

  val names : string list
  val versions : string StringMap.t

  val get_options : unit -> options
  val make : options -> Scheduler.t -> t
    (**
Make the application.
It calls on all components of the application:
[COMPONENT.make], [COMPONENT.get_ports] and [COMPONENT.get_description].
Ports and descriptions are added in [RuntimeType.Ports] and [RuntimeType.Description].
See [Runtime.make] implementation.
**)

  val run : t -> Scheduler.t -> t
    (**
Run all components.
This function is called by Runtime when all components have been made
via their [make] function.
*)

  val close : t -> Scheduler.t -> unit
    (**
Close all components at the end of the program.
*)

end
Something went wrong with that request. Please try again.