blob: 54bc5ee7f7c4b7589e98d093acab083612a68a98 (
plain) (
blame)
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
|
(** Internal ratelimit route mapping. *)
open Core
open Async
(** Type for mapping route -> {!rl}. *)
module RouteMap : module type of Map.Make(String)
(** Type representing ratelimit information. *)
type rl = {
limit: int;
remaining: int;
reset: int;
} [@@deriving sexp]
(** Type representing the specific case of {!RouteMap}. *)
type t = ((rl, read_write) Mvar.t) RouteMap.t
val get_rl :
[ `Get | `Delete | `Post | `Patch | `Put ] ->
string ->
t ->
(rl, read_write) Mvar.t * t
(** Converts Cohttp header data into ratelimit information.
@return Some of ratelimit information or None on bad headers
*)
val rl_of_header : Cohttp.Header.t -> rl option
(** Default for type rl. Used for prepopulating routes. *)
val default : rl
(** Empty ratelimit route map. *)
val empty : t
(** Analogous to {!RouteMap.update}. *)
val update : 'a RouteMap.t -> string -> f:('a option -> 'a) -> 'a RouteMap.t
(** Analogous to {!RouteMap.find}. *)
val find : 'a RouteMap.t -> string -> 'a option
(** Analogous to {!RouteMap.find_exn}. *)
val find_exn : 'a RouteMap.t -> string -> 'a
|