My agentic slop goes here. Not intended for anyone else!
at main 1.0 kB view raw
1let src = Logs.Src.create "requests.timeout" ~doc:"HTTP Request Timeouts" 2module Log = (val Logs.src_log src : Logs.LOG) 3 4type t = { 5 connect : float option; 6 read : float option; 7 total : float option; 8} 9 10let none = { 11 connect = None; 12 read = None; 13 total = None; 14} 15 16let create ?connect ?read ?total () = { 17 connect; 18 read; 19 total; 20} 21 22let default = { 23 connect = Some 10.0; 24 read = Some 30.0; 25 total = None; 26} 27 28let connect t = t.connect 29let read t = t.read 30let total t = t.total 31 32let pp ppf t = 33 let items = [] in 34 let items = match t.connect with 35 | Some c -> (Printf.sprintf "connect:%.1fs" c) :: items 36 | None -> items 37 in 38 let items = match t.read with 39 | Some r -> (Printf.sprintf "read:%.1fs" r) :: items 40 | None -> items 41 in 42 let items = match t.total with 43 | Some tot -> (Printf.sprintf "total:%.1fs" tot) :: items 44 | None -> items 45 in 46 match items with 47 | [] -> Format.fprintf ppf "no timeouts" 48 | _ -> Format.fprintf ppf "%s" (String.concat ", " (List.rev items))