package dune-rpc

  1. Overview
  2. Docs

Source file procedures.ml

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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
open Import
open Types
open Exported_types

module Public = struct
  module Ping = struct
    let v1 =
      Decl.Request.make_current_gen ~req:Conv.unit ~resp:Conv.unit ~version:1

    let decl = Decl.Request.make ~method_:"ping" ~generations:[ v1 ]
  end

  module Diagnostics = struct
    let v1 =
      Decl.Request.make_current_gen ~req:Conv.unit
        ~resp:(Conv.list Diagnostic.sexp)
        ~version:1

    let decl = Decl.Request.make ~method_:"diagnostics" ~generations:[ v1 ]
  end

  module Shutdown = struct
    let v1 = Decl.Notification.make_current_gen ~conv:Conv.unit ~version:1

    let decl = Decl.Notification.make ~method_:"shutdown" ~generations:[ v1 ]
  end

  module Format_dune_file = struct
    module V1 = struct
      let req =
        let open Conv in
        let path = field "path" (required string) in
        let contents = field "contents" (required string) in
        let to_ (path, contents) = (path, `Contents contents) in
        let from (path, `Contents contents) = (path, contents) in
        iso (record (both path contents)) to_ from
    end

    let v1 =
      Decl.Request.make_current_gen ~req:V1.req ~resp:Conv.string ~version:1

    let decl = Decl.Request.make ~method_:"format-dune-file" ~generations:[ v1 ]
  end

  module Promote = struct
    let v1 =
      Decl.Request.make_current_gen ~req:Path.sexp ~resp:Conv.unit ~version:1

    let decl = Decl.Request.make ~method_:"promote" ~generations:[ v1 ]
  end

  module Build_dir = struct
    let v1 =
      Decl.Request.make_current_gen ~req:Conv.unit ~resp:Path.sexp ~version:1

    let decl = Decl.Request.make ~method_:"build_dir" ~generations:[ v1 ]
  end

  let ping = Ping.decl

  let diagnostics = Diagnostics.decl

  let shutdown = Shutdown.decl

  let format_dune_file = Format_dune_file.decl

  let promote = Promote.decl

  let build_dir = Build_dir.decl
end

module Server_side = struct
  module Abort = struct
    let v1 = Decl.Notification.make_current_gen ~conv:Message.sexp ~version:1

    let decl =
      Decl.Notification.make ~method_:"notify/abort" ~generations:[ v1 ]
  end

  module Log = struct
    let v1 = Decl.Notification.make_current_gen ~conv:Message.sexp ~version:1

    let decl = Decl.Notification.make ~method_:"notify/log" ~generations:[ v1 ]
  end

  let abort = Abort.decl

  let log = Log.decl
end

module Poll = struct
  let cancel_gen = Decl.Notification.make_current_gen ~conv:Id.sexp ~version:1

  module Name = struct
    include String

    let make s = s
  end

  type 'a t =
    { poll : (Id.t, 'a option) Decl.request
    ; cancel : Id.t Decl.notification
    ; name : Name.t
    }

  let make name generations =
    let poll = Decl.Request.make ~method_:("poll/" ^ name) ~generations in
    let cancel =
      Decl.Notification.make ~method_:("cancel-poll/" ^ name)
        ~generations:[ cancel_gen ]
    in
    { poll; cancel; name }

  let poll t = t.poll

  let cancel t = t.cancel

  let name t = t.name

  module Progress = struct
    let name = "progress"

    let v1 =
      Decl.Request.make_current_gen ~req:Id.sexp
        ~resp:(Conv.option Progress.sexp)
        ~version:1
  end

  module Diagnostic = struct
    let name = "diagnostic"

    let v1 =
      Decl.Request.make_current_gen ~req:Id.sexp
        ~resp:(Conv.option (Conv.list Diagnostic.Event.sexp))
        ~version:1
  end

  module Job = struct
    let name = "running-jobs"

    let v1 =
      Decl.Request.make_current_gen ~req:Id.sexp
        ~resp:(Conv.option (Conv.list Job.Event.sexp))
        ~version:1
  end

  let progress =
    let open Progress in
    make name [ v1 ]

  let diagnostic =
    let open Diagnostic in
    make name [ v1 ]

  let running_jobs =
    let open Job in
    make name [ v1 ]
end
OCaml

Innovation. Community. Security.