Source file job.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
open Capnp_rpc_lwt

type t = Api.Service.Job.t Capability.t

type id = string

type status = {
  id : string;
  description : string;
  can_cancel : bool;
  can_rebuild : bool;
}

module Job = Api.Client.Job

let log ~start t =
  let open Job.Log in
  let request, params = Capability.Request.create Params.init_pointer in
  Params.start_set params start;
  Capability.call_for_value t method_id request |> Lwt_result.map @@ fun x ->
  (Results.log_get x, Results.next_get x)

let status t =
  let open Job.Status in
  let request = Capability.Request.create_no_args () in
  Capability.call_for_value t method_id request |> Lwt_result.map @@ fun x ->
  {
    id = Results.id_get x;
    description = Results.description_get x;
    can_cancel = Results.can_cancel_get x;
    can_rebuild = Results.can_rebuild_get x;
  }

let cancel t =
  let open Job.Cancel in
  let request = Capability.Request.create_no_args () in
  Capability.call_for_unit t method_id request

let rebuild t =
  let open Job.Rebuild in
  let request = Capability.Request.create_no_args () in
  Capability.call_for_caps t method_id request Results.job_get_pipelined

let approve_early_start t =
  let open Job.ApproveEarlyStart in
  let request = Capability.Request.create_no_args () in
  Capability.call_for_unit t method_id request