diff options
| author | Matias Goldfeld <[email protected]> | 2021-01-27 23:52:50 -0500 |
|---|---|---|
| committer | Matias Goldfeld <[email protected]> | 2021-01-27 23:52:50 -0500 |
| commit | 4a95a2a16273384072a767ff44e5db772224d6a4 (patch) | |
| tree | f0fc6ff32bbf586b94d573ecb4c99b17324ea0ee | |
| parent | Fixed snowflake for 32 bit machines (diff) | |
| download | disml-4a95a2a16273384072a767ff44e5db772224d6a4.tar.xz disml-4a95a2a16273384072a767ff44e5db772224d6a4.zip | |
More 32 bit fixes
| -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 ec6cb2c..afb2610 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 limit.remaining > 0 then process ()
+ in if Int64.(limit.remaining > 0L) then process ()
else
- let time = Time.(Span.of_int_sec limit.reset |> of_span_since_epoch) in
+ let time = Time.(limit.reset |> Int63.of_int64_trunc |> Span.of_int63_seconds |> 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 9f149df..5f26012 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: int; - remaining: int; - reset: int; + limit: int64; + remaining: int64; + reset: int64; } [@@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 = Int.of_string lim in - let remaining = Int.of_string rem in - let reset = Int.of_string re in + let limit = Int64.of_string lim in + let remaining = Int64.of_string rem in + let reset = Int64.of_string re in Some { limit; remaining; reset; } | _ -> None -let default = { limit = 1; remaining = 1; reset = 0; } +let default = { limit = 1L; remaining = 1L; reset = 0L; } 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 54bc5ee..f4a8d59 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: int; - remaining: int; - reset: int; + limit: int64; + remaining: int64; + reset: int64; } [@@deriving sexp] (** Type representing the specific case of {!RouteMap}. *) |