diff --git a/lib/ash_oban.ex b/lib/ash_oban.ex index 83b9ddf..4621ba0 100644 --- a/lib/ash_oban.ex +++ b/lib/ash_oban.ex @@ -6,23 +6,23 @@ defmodule AshOban do defmodule Trigger do @type t :: %__MODULE__{ action: atom, - condition: Ash.Expr.t() + where: Ash.Expr.t() } - defstruct [:action, :condition] + defstruct [:action, :where] end @trigger %Spark.Dsl.Entity{ name: :trigger, target: Trigger, - args: [:action, :condition], + args: [:action], imports: [Ash.Filter.TemplateHelpers], schema: [ action: [ type: :atom, doc: "The action to be triggered" ], - condition: [ + where: [ type: :any, doc: "The filter expression to determine if something should be triggered" ] @@ -39,5 +39,10 @@ defmodule AshOban do sections: [@triggers] } - use Spark.Dsl.Extension, sections: [@oban] + use Spark.Dsl.Extension, + sections: [@oban], + verifiers: [ + # This is a bit dumb, a verifier probably shouldn't have side effects + AshOban.Verifiers.DefineSchedulers + ] end diff --git a/lib/verifiers/define_schedulers.ex b/lib/verifiers/define_schedulers.ex new file mode 100644 index 0000000..1e95bba --- /dev/null +++ b/lib/verifiers/define_schedulers.ex @@ -0,0 +1,14 @@ +defmodule AshOban.Verifiers.DefineSchedulers do + use Spark.Dsl.Verifier + + def verify(dsl_state) do + # TODO + # dsl_state + # |> AshOban.Info.oban_triggers() + # |> Enum.each(fn trigger -> + # IO.inspect(trigger) + # end) + + :ok + end +end diff --git a/test/ash_oban_test.exs b/test/ash_oban_test.exs index 8e4bbfe..cbdd28f 100644 --- a/test/ash_oban_test.exs +++ b/test/ash_oban_test.exs @@ -9,7 +9,9 @@ defmodule AshObanTest do oban do triggers do - trigger :process, expr(processed != true) + trigger :process do + where expr(processed != true) + end end end