package octez-libs
A package that contains multiple base libraries used by the Octez suite
Install
Dune Dependency
Authors
Maintainers
Sources
tezos-octez-v20.1.tag.bz2
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/src/octez-libs.base/worker_types.ml.html
Source file worker_types.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 159 160 161 162 163
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************) open Error_monad type error += Terminated type worker_status = | Launching of Time.System.t | Running of Time.System.t | Closing of Time.System.t * Time.System.t | Closed of Time.System.t * Time.System.t * error list option let worker_status_encoding error_encoding = let open Data_encoding in union [ case (Tag 0) ~title:"Launching" (obj2 (req "phase" (constant "launching")) (req "since" Time.System.encoding)) (function Launching t -> Some ((), t) | _ -> None) (fun ((), t) -> Launching t); case (Tag 1) ~title:"Running" (obj2 (req "phase" (constant "running")) (req "since" Time.System.encoding)) (function Running t -> Some ((), t) | _ -> None) (fun ((), t) -> Running t); case (Tag 2) ~title:"Closing" (obj3 (req "phase" (constant "closing")) (req "birth" Time.System.encoding) (req "since" Time.System.encoding)) (function Closing (t0, t) -> Some ((), t0, t) | _ -> None) (fun ((), t0, t) -> Closing (t0, t)); case (Tag 3) ~title:"Closed" (obj3 (req "phase" (constant "closed")) (req "birth" Time.System.encoding) (req "since" Time.System.encoding)) (function Closed (t0, t, None) -> Some ((), t0, t) | _ -> None) (fun ((), t0, t) -> Closed (t0, t, None)); case (Tag 4) ~title:"Crashed" (obj4 (req "phase" (constant "crashed")) (req "birth" Time.System.encoding) (req "since" Time.System.encoding) (req "errors" error_encoding)) (function | Closed (t0, t, Some errs) -> Some ((), t0, t, errs) | _ -> None) (fun ((), t0, t, errs) -> Closed (t0, t, Some errs)); ] type worker_information = { instances_number : int; wstatus : worker_status; queue_length : int; } let worker_information_encoding error_encoding = Data_encoding.( conv (fun {instances_number; wstatus; queue_length} -> (instances_number, wstatus, queue_length)) (fun (instances_number, wstatus, queue_length) -> {instances_number; wstatus; queue_length}) (obj3 (req "instances" int31) (req "status" (worker_status_encoding error_encoding)) (req "queue_length" int31))) type request_status = { pushed : Time.System.t; treated : Time.System.t; completed : Time.System.t; } let request_status_encoding = let open Data_encoding in conv (fun {pushed; treated; completed} -> (pushed, treated, completed)) (fun (pushed, treated, completed) -> {pushed; treated; completed}) (obj3 (req "pushed" Time.System.encoding) (req "treated" Time.System.encoding) (req "completed" Time.System.encoding)) type 'req full_status = { status : worker_status; pending_requests : (Time.System.t * 'req) list; current_request : (Time.System.t * Time.System.t * 'req) option; } let full_status_encoding req_encoding error_encoding = let open Data_encoding in let requests_encoding = list (obj2 (req "pushed" Time.System.encoding) (req "request" (dynamic_size req_encoding))) in let current_request_encoding = obj3 (req "pushed" Time.System.encoding) (req "treated" Time.System.encoding) (req "request" req_encoding) in conv (fun {status; pending_requests; current_request} -> (status, pending_requests, current_request)) (fun (status, pending_requests, current_request) -> {status; pending_requests; current_request}) (obj3 (req "status" (worker_status_encoding error_encoding)) (req "pending_requests" requests_encoding) (opt "current_request" current_request_encoding)) let pp_status ppf {pushed; treated; completed} = Format.fprintf ppf "Request pushed on %a, treated in %a, completed in %a" Time.System.pp_hum pushed Ptime.Span.pp (Ptime.diff treated pushed) Ptime.Span.pp (Ptime.diff completed treated) let pp_status_completed ppf {completed; treated; _} = Format.fprintf ppf "%a" Ptime.Span.pp (Ptime.diff completed treated)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>