aboutsummaryrefslogtreecommitdiff
path: root/lib/http/http.ml
diff options
context:
space:
mode:
authorAdelyn Breedlove <[email protected]>2019-03-04 20:26:18 -0700
committerAdelyn Breedlove <[email protected]>2019-03-04 20:26:18 -0700
commitd6aac749a38159c986fee3e0b4acb87af834426f (patch)
tree7189faa42a1aedeab735af0c2f7d4276e681b5e5 /lib/http/http.ml
parentAdd time back to ping example (diff)
downloaddisml-d6aac749a38159c986fee3e0b4acb87af834426f.tar.xz
disml-d6aac749a38159c986fee3e0b4acb87af834426f.zip
Add basic time back to RL handler
Diffstat (limited to 'lib/http/http.ml')
-rw-r--r--lib/http/http.ml10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/http/http.ml b/lib/http/http.ml
index c23c326..5e75cb4 100644
--- a/lib/http/http.ml
+++ b/lib/http/http.ml
@@ -41,7 +41,6 @@ module Base = struct
Lwt_result.fail @@ Printf.sprintf "Unsuccessful response received: %d - %s" code body
let request ?(body=`Null) ?(query=[]) m path =
- Logs_lwt.info (fun m -> m "Making HTTP request. Path: %s" path) >>= fun () ->
let limit, rlm = Rl.get_rl m path !rl in
rl := rlm;
Lwt_mvar.take limit >>= fun limit ->
@@ -58,10 +57,11 @@ module Base = struct
>>= process_response path
in if limit.remaining > 0 then process ()
else
- (* let time = Time.(Span.of_int_sec limit.reset |> of_span_since_epoch) in
- Logs.debug (fun m -> m "Rate-limiting [Route: %s] [Duration: %d ms]" path Time.(diff time (Time.now ()) |> Span.to_ms |> Float.to_int) );
- Clock.at time >>= process *)
- process ()
+ let time = float_of_int limit.reset -. Unix.time () in
+ Logs_lwt.info (fun m -> m
+ "Rate-limiting [Route: %s] [Duration: %f s]"
+ path time) >>= fun () ->
+ Lwt_unix.sleep time >>= process
end
let r_map f = function