Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork21
Open
Description
Code of Conduct
- I agree to follow this project's Code of Conduct
AI Policy
- I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.
Versions
$ elixir --versionErlang/OTP 28 [erts-16.1.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] [dtrace]Elixir 1.19.1 (compiled with Erlang/OTP 28)$ mix deps |grep reactor* reactor 0.17.0 (Hex package) (mix) locked at 0.17.0 (reactor) 3c3bf716Operating system
macOS
Current Behavior
reactor/documentation/tutorials/02-error-handling.md
Lines 442 to 454 in08c4d31
| # NEW: Backoff implementation | |
| @impltrue | |
| defbackoff(error,_arguments, context,_step)do | |
| case errordo | |
| %{type::network_timeout}-> | |
| # Exponential backoff for network issues | |
| retry_count=Map.get(context,:current_try,0) | |
| delay_ms=:math.pow(2, retry_count)*1000|>round()|>min(30_000) | |
| IO.puts("⏰ Network timeout - backing off for#{delay_ms}ms") | |
| delay_ms | |
| %{type::rate_limit}-> | |
| # Longer fixed delay for rate limiting |
matching on theerror, as above, does not work because the error is of type%Reactor.Error.Invalid.RunStepError{}. To make it work, you have to do thecase match onerror.error or destructure the error in the function arg (def backoff(%{error: error}, _arguments, context, _step) do).
I'm not sure if this is just a mistake in the tutorial, because thecompensate function matching works fineonerror itself. Is it expected thatbackoff is passed a "full"Reactor error type?
Reproduction
- Follow tutorial up to and includinghttps://hexdocs.pm/reactor/02-error-handling.html#implementing-backoff-strategies
- in
iex -S mixrun:
{:error,reason}=Reactor.run(ResilientUserRegistration,%{email:"timeout@example.com",password:"secretpassword123"})
Expected Behavior
Following the tutorial steps,iex tests trigger backoff delay.