diff options
| author | Matias Goldfeld <[email protected]> | 2021-01-29 13:41:00 -0500 |
|---|---|---|
| committer | Matias Goldfeld <[email protected]> | 2021-01-29 13:41:00 -0500 |
| commit | 1d7fc27e505ff0eb9db3449404a2d4383a64673a (patch) | |
| tree | a8d1751e035bedfea9edb1e1b838e4a6f381a140 | |
| parent | Revert "More Int64 refactors" (diff) | |
| download | disml-1d7fc27e505ff0eb9db3449404a2d4383a64673a.tar.xz disml-1d7fc27e505ff0eb9db3449404a2d4383a64673a.zip | |
Revert "More 32 bit fixes"
This reverts commit 4a95a2a16273384072a767ff44e5db772224d6a4.
| -rw-r--r-- | lib/http/http.ml | 4 | ||||
| -rw-r--r-- | lib/http/rl.ml | 14 | ||||
| -rw-r--r-- | lib/http/rl.mli | 6 |
3 files changed, 12 insertions, 12 deletions
diff --git a/lib/http/http.ml b/lib/http/http.ml index afb2610..ec6cb2c 100644 --- a/lib/http/http.ml +++ b/lib/http/http.ml @@ -68,9 +68,9 @@ module Base = struct | `Post -> Cohttp_async.Client.post ~headers ~body uri
| `Put -> Cohttp_async.Client.put ~headers ~body uri)
>>= process_response path
- in if Int64.(limit.remaining > 0L) then process ()
+ in if limit.remaining > 0 then process ()
else
- let time = Time.(limit.reset |> Int63.of_int64_trunc |> Span.of_int63_seconds |> of_span_since_epoch) in
+ 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
end
diff --git a/lib/http/rl.ml b/lib/http/rl.ml index 5f26012..9f149df 100644 --- a/lib/http/rl.ml +++ b/lib/http/rl.ml @@ -4,9 +4,9 @@ open Async module RouteMap = Map.Make(String) type rl = { - limit: int64; - remaining: int64; - reset: int64; + limit: int; + remaining: int; + reset: int; } [@@deriving sexp] (* TODO improve route getting, use Date header *) @@ -25,13 +25,13 @@ let rl_of_header h = let module C = Cohttp.Header in match C.get h "X-RateLimit-Limit", C.get h "X-RateLimit-Remaining", C.get h "X-RateLimit-Reset" with | Some lim, Some rem, Some re -> - let limit = Int64.of_string lim in - let remaining = Int64.of_string rem in - let reset = Int64.of_string re in + let limit = Int.of_string lim in + let remaining = Int.of_string rem in + let reset = Int.of_string re in Some { limit; remaining; reset; } | _ -> None -let default = { limit = 1L; remaining = 1L; reset = 0L; } +let default = { limit = 1; remaining = 1; reset = 0; } let empty : t = RouteMap.empty let update = RouteMap.update let find = RouteMap.find diff --git a/lib/http/rl.mli b/lib/http/rl.mli index f4a8d59..54bc5ee 100644 --- a/lib/http/rl.mli +++ b/lib/http/rl.mli @@ -8,9 +8,9 @@ module RouteMap : module type of Map.Make(String) (** Type representing ratelimit information. *) type rl = { - limit: int64; - remaining: int64; - reset: int64; + limit: int; + remaining: int; + reset: int; } [@@deriving sexp] (** Type representing the specific case of {!RouteMap}. *) |