ash-project / reactor

Reactor is a dynamic, concurrent, dependency resolving saga orchestrator.
https://ash-hq.org/
MIT License
44 stars 6 forks source link

Reactor compiler errors when using run/3 function #128

Closed ekosz closed 2 weeks ago

ekosz commented 2 weeks ago

Describe the bug The documentation states that using a non-module run function inside a step should have arity 3. But when that's supplied one gets and error claiming it should be run/2 or run/1 instead. Either the verification is wrong or the docs are wrong.

To Reproduce

defmodule FooReactor do
  use Reactor

  input(:foo)

  step :do_foo do
    run fn _, _, _ ->
      {:ok, :noop}
    end
  end
end

Produces the error:

== Compilation error in file lib/foo.ex ==
** (Spark.Error.DslError) [FooReactor]
reactor -> step -> do_foo:
  expected :run option to match at least one given type, but didn't match any. Here are the reasons why it didn't match each of the allowed types:

  * expected MFA or function of arity 2 in :run option, got: &FooReactor.run_0_generated_8536D4A244549FB51F4D5E7554E6D6E2/3
  * expected MFA or function of arity 1 in :run option, got: &FooReactor.run_0_generated_8536D4A244549FB51F4D5E7554E6D6E2/3
    (reactor 0.10.0) /Users/e/Code/ekg/deps/spark/lib/spark/dsl/extension.ex:1174: Reactor.Dsl.Reactor.Step.__build__/3
    (spark 2.2.30) lib/spark/dsl/extension/entity.ex:91: Spark.Dsl.Extension.Entity.handle/6
    lib/foo.ex:27: (module)


**Expected behavior**
Either the verifier is updated to match the docs, or the docs are updated to match the verifier.

**Runtime**
 - Spark version: `2.2.30`
 - Version: `0.10.0`

**Additional context**
If this is just an issue with the docs, please let me know! I'm happy to open a PR to fix them