Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Docs: Tutorial "Implementing backoff strategies" backoff function not matching on error #277

Open
Labels
bugSomething isn't working
@patryk-s

Description

@patryk-s

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) 3c3bf716

Operating system

macOS

Current Behavior

# 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

  1. Follow tutorial up to and includinghttps://hexdocs.pm/reactor/02-error-handling.html#implementing-backoff-strategies
  2. iniex -S mix run:
{:error,reason}=Reactor.run(ResilientUserRegistration,%{email:"timeout@example.com",password:"secretpassword123"})

Expected Behavior

Following the tutorial steps,iex tests trigger backoff delay.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp