ash_oban icon indicating copy to clipboard operation
ash_oban copied to clipboard

Can't trigger a job that uses a generic action

Open andr-ec opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe. If the action is a generic action, a job won't trigger it will error. Some times I we'll need a trigger that doesn't necessarily update or destroy.

"** (Ash.Error.Unknown.UnknownError) ** (CaseClauseError) no case clause matching: :action\n    (ash 3.4.32) lib/ash/changeset/changeset.ex:1241: Ash.Changeset.for_action/4\n    (otterwake 0.1.0) deps/ash_oban/lib/transformers/define_schedulers.ex:727: Otterwake.VideoPlatform.SimulcastTarget.AshOban.Worker.StreamSimulcast.perform/1\n    (oban 2.18.3) lib/oban/queue/executor.ex:145: Oban.Queue.Executor.perform/1\n    (oban 2.18.3) lib/oban/queue/executor.ex:77: Oban.Queue.Executor.call/1\n    (oban 2.18.3) lib/oban/engines/inline.ex:97: Oban.Engines.Inline.execute_job/2\n    (oban 2.18.3) lib/oban/engines/inline.ex:37: Oban.Engines.Inline.insert_job/3\n    (oban 2.18.3) lib/oban/engine.ex:192: anonymous fn/4 in Oban.Engine.insert_job/3\n    (oban 2.18.3) lib/oban/engine.ex:339: anonymous fn/3 in Oban.Engine.with_span/4\n    (telemetry 1.3.0) /home/andre/Documents/otterwake/deps/telemetry/src/telemetry.erl:324: :telemetry.span/3\n    (oban 2.18.3) lib/oban.ex:611: Oban.insert!/3\n    (elixir 1.17.3) elixir.erl:386: :elixir.eval_external_handler/3\n    (stdlib 4.3.1.4) erl_eval.erl:748: :erl_eval.do_apply/7\n    (elixir 1.17.3) elixir.erl:364: :elixir.eval_forms/4\n    (elixir 1.17.3) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1\n    lib/livebook/runtime/evaluator.ex:635: anonymous fn/3 in Livebook.Runtime.Evaluator.eval/4\n    (elixir 1.17.3) lib/code.ex:621: Code.with_diagnostics/2\n    lib/livebook/runtime/evaluator.ex:629: Livebook.Runtime.Evaluator.eval/4\n    lib/livebook/runtime/evaluator.ex:437: Livebook.Runtime.Evaluator.continue_do_evaluate_code/6\n    lib/livebook/runtime/evaluator.ex:337: Livebook.Runtime.Evaluator.loop/1\n    (stdlib 4.3.1.4) proc_lib.erl:240: :proc_lib.init_p_do_apply/3\n"

Describe the solution you'd like A clear and concise description of what you want to happen. triggers supporting generic actions

Describe alternatives you've considered using an update action

Express the feature either with a change to resource syntax, or with a change to the resource interface

For example

    triggers do
      # add a trigger called `:process`
      trigger :stream_simulcast do
        # this trigger calls the `process` action
        action :say_hello
        queue(:default)
        scheduler_cron(false)

        worker_read_action(:read)
        # error :error
        # this should check that the stream is active
        # where expr(status == :active)
      end
    end
  end

Or

    action :say_hello, :string do
      run fn input, _ ->
        {:ok, "Hello"}
      end
    end

Additional context Add any other context or screenshots about the feature request here.

andr-ec avatar Oct 18 '24 03:10 andr-ec

Generic actions are currently not supported. PRs welcome!

zachdaniel avatar Oct 18 '24 11:10 zachdaniel

@zachdaniel is it ok to copy and modify from define_action_workers https://github.com/ash-project/ash_oban/blob/9a5ce56c56f0be122329699a668c52627852a8b2/lib/transformers/define_action_workers.ex#L75 and pattern match trigger_action_type here? https://github.com/ash-project/ash_oban/blob/9a5ce56c56f0be122329699a668c52627852a8b2/lib/transformers/define_schedulers.ex#L577

tunchamroeun avatar Nov 28 '24 02:11 tunchamroeun

Is this issue still current?

xantrac avatar Aug 04 '25 19:08 xantrac

Nope, forgot to close it

zachdaniel avatar Aug 04 '25 22:08 zachdaniel