aboutsummaryrefslogtreecommitdiffstats
path: root/docs/init.org
blob: 746ce03afdb6626c8a24893b589fad30b5641903 (plain) (blame)
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
The init system is the part of RNT responsible from taking a description of what a live system should look like and instantiating a system that matches this description, constructing and connecting different components as necessary. It is not a supervisor, that is, it is not responsible for maintaining the state of the system once it has been built, although it provides functionality that could support the implementation of a supervisor.

More concretely, the role of the init system is to build a *system* out of a set of *components*. *Components* are the description of a building block of systems that can either require *services* from an existing component, extend an existing component and provide services to other components. A component that extends another component implicitly requires that component. Components, through this provision and requirement relationship, form a directed acyclic graph. Concretely, a component might look something like this:

#+begin_src ocaml
type service = ..

type component =
  { provides: service BatSet.t;
    requires: service BatSet.t;
    (* extends: extension list; *)
    construct: (service, Handle.t) BatMap.t -> (Handle.t, Concepts.Condition.condition) result }



module type SUBSYSTEM = struct
  type t
  val create : unit -> t
  val destroy : t -> unit
end

module MySubsystem : SUBSYSTEM = struct

end



type ('a, 'b) service = ..

type ('a, 'b) service += ServiceThatTakesAnInt
let makeServiceThatTakesAnInt : int service = ServiceThatTakesAnInt

type ('a, 'b) extension = ('a, 'b) service * ('a -> ('b, Concepts.Condition.condition) result)

type component =
  { provides: service;
    extends: extension BatSet.t
    extend: ()}

let _ = Component.make
	      ~provides:MySubsystem
          ~extends:[extend Subsystem (fun h ->
                        MySubsystem.make <><>)]

let _ = Component.make
	      ~requires:[SubsystemRegistry]
          ~provides:[MySubsystem]
          ~mount:(fun h ->
            let myself = MySubstystem.make <><> in
            SubssystemRegistry.register myself;
            myself)
          ~unmount:(fun h myself ->
            Lifecycle.destroy myself)

(* options:
   - object destroy itself on unmount through lifecycles
     - would require us to be able to notify the owner, which would mean we have to know who the owner is
 ,*)



type component =
  { ex}
#+end_src