Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 112 lines (91 sloc) 3.097 kB
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18
19 (**
20 Module type COMPONENT accepted by the Runtime layer.
21 Runtime merge several COMPONENT in one APPLICATION.
22 @author Cedric Soulas
23 *)
24
25 module type COMPONENT =
26 sig
27 type options
28 type t
29
30 val name : string
31 val version : string
32
33 val default_options : options
34 (** Default options *)
35
36 val spec_args : string -> (options ServerArg.arg_parser) list
37 (**
38 [spec_args name] return the command line parser specification for type options.
39 The name can be used to prefix the command line to avoid
40 command line conflicts when adding several identical component.
41 Example: [HttpServerOptions.spec_args].
42 *)
43
44 val make : string -> options -> Scheduler.t -> t
45 (**
46 [make name opt sched] make a named component of type [t]
47 from a set of options [opt].
48 See [run].
49 *)
50
51 val get_ports : t -> Scheduler.t -> RuntimeType.Ports.t
52 (**
53 Return the list of ports needed by the component.
54 See [RuntimeType.Ports].
55 *)
56
57 val get_description : t -> Scheduler.t -> RuntimeType.Description.t
58 (**
59 Return the description of the component, to be used as
60 a port by another component.
61 See [RuntimeType.Description]
62 *)
63
64 val run : t -> Scheduler.t -> t
65 (**
66 Run the component of type [t].
67 This function is called when all components have been made
68 via their [make] function.
69 *)
70
71 val close : t -> Scheduler.t -> unit
72 (**
73 Close the component.
74 This function is called at the end of the program.
75 *)
76 end
77
78 (**
79 Module type APPLICATION produced by the Runtime layer from a set of COMPONENT.
80 *)
81 module type APPLICATION =
82 sig
83 type options
84 type t
85
86 val names : string list
87 val versions : string StringMap.t
88
89 val get_options : unit -> options
90 val make : options -> Scheduler.t -> t
91 (**
92 Make the application.
93 It calls on all components of the application:
94 [COMPONENT.make], [COMPONENT.get_ports] and [COMPONENT.get_description].
95 Ports and descriptions are added in [RuntimeType.Ports] and [RuntimeType.Description].
96 See [Runtime.make] implementation.
97 **)
98
99 val run : t -> Scheduler.t -> t
100 (**
101 Run all components.
102 This function is called by Runtime when all components have been made
103 via their [make] function.
104 *)
105
106 val close : t -> Scheduler.t -> unit
107 (**
108 Close all components at the end of the program.
109 *)
110
111 end
Something went wrong with that request. Please try again.