Exponential backoff retry logic
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-retry: enable MDX on lib/retry.mli, fix broken doc example

Run mdx on lib/retry.mli so the {[ ... ]} odoc block now type-checks.

The example referenced free `clock` and `connect_to_server`, used
`Eio.Net.Connection_refused` (which is an Eio.Net.error variant, not
an exception, and the expected predicate type is `exn -> bool`), and
`let ... in` chains that do not parse at the toplevel.

Wrapped in `let run connect_to_server = Eio_main.run @@ ...` so the
example takes the user-supplied operation as a parameter; switched
the predicate to `Failure _` (a real exn) so the should_retry has
the right type.

+13 -7
+4
lib/dune
··· 2 2 (name retry) 3 3 (public_name retry) 4 4 (libraries eio fmt logs)) 5 + 6 + (mdx 7 + (files retry.mli) 8 + (libraries retry eio eio.unix eio_main))
+9 -7
lib/retry.mli
··· 10 10 11 11 {1 Example} 12 12 {[ 13 - let config = Retry.config ~max_retries:5 () in 14 - let should_retry = function 15 - | Eio.Net.Connection_refused _ -> true 16 - | _ -> false 17 - in 18 - Retry.with_retry ~clock ~config ~should_retry (fun () -> 19 - connect_to_server ()) 13 + let run connect_to_server = 14 + Eio_main.run @@ fun env -> 15 + let clock = Eio.Stdenv.clock env in 16 + let config = Retry.config ~max_retries:5 () in 17 + let should_retry = function 18 + | Failure _ -> true 19 + | _ -> false 20 + in 21 + Retry.with_retry ~clock ~config ~should_retry connect_to_server 20 22 ]} *) 21 23 22 24 type config = {