My agentic slop goes here. Not intended for anyone else!
1(** HTTP request retry logic with exponential backoff *)
2
3open Eio
4
5(** Log source for retry operations *)
6val src : Logs.Src.t
7
8(** Retry configuration *)
9type config = {
10 max_retries : int; (** Maximum number of retry attempts *)
11 backoff_factor : float; (** Exponential backoff multiplier *)
12 backoff_max : float; (** Maximum backoff time in seconds *)
13 status_forcelist : int list; (** HTTP status codes to retry *)
14 allowed_methods : Method.t list; (** Methods safe to retry *)
15 respect_retry_after : bool; (** Honor Retry-After response header *)
16 jitter : bool; (** Add randomness to prevent thundering herd *)
17}
18
19(** Default retry configuration *)
20val default_config : config
21
22(** Create a custom retry configuration *)
23val create_config :
24 ?max_retries:int ->
25 ?backoff_factor:float ->
26 ?backoff_max:float ->
27 ?status_forcelist:int list ->
28 ?allowed_methods:Method.t list ->
29 ?respect_retry_after:bool ->
30 ?jitter:bool ->
31 unit -> config
32
33(** Check if a request should be retried *)
34val should_retry : config:config -> method_:Method.t -> status:int -> bool
35
36(** Calculate backoff delay for a given attempt *)
37val calculate_backoff : config:config -> attempt:int -> float
38
39(** Parse Retry-After header value (seconds or HTTP date) *)
40val parse_retry_after : string -> float option
41
42(** Execute a request with retry logic *)
43val with_retry :
44 sw:Switch.t ->
45 clock:_ Time.clock ->
46 config:config ->
47 f:(unit -> 'a) ->
48 should_retry_exn:(exn -> bool) ->
49 'a
50
51(** Pretty print retry configuration *)
52val pp_config : Format.formatter -> config -> unit
53
54(** Log retry attempt information *)
55val log_retry : attempt:int -> delay:float -> reason:string -> unit