mirror of
https://github.com/ash-project/ash_oban.git
synced 2024-09-20 05:13:15 +12:00
WIP
This commit is contained in:
parent
223124bd77
commit
316a77a7f2
3 changed files with 27 additions and 6 deletions
|
@ -6,23 +6,23 @@ defmodule AshOban do
|
||||||
defmodule Trigger do
|
defmodule Trigger do
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
action: atom,
|
action: atom,
|
||||||
condition: Ash.Expr.t()
|
where: Ash.Expr.t()
|
||||||
}
|
}
|
||||||
|
|
||||||
defstruct [:action, :condition]
|
defstruct [:action, :where]
|
||||||
end
|
end
|
||||||
|
|
||||||
@trigger %Spark.Dsl.Entity{
|
@trigger %Spark.Dsl.Entity{
|
||||||
name: :trigger,
|
name: :trigger,
|
||||||
target: Trigger,
|
target: Trigger,
|
||||||
args: [:action, :condition],
|
args: [:action],
|
||||||
imports: [Ash.Filter.TemplateHelpers],
|
imports: [Ash.Filter.TemplateHelpers],
|
||||||
schema: [
|
schema: [
|
||||||
action: [
|
action: [
|
||||||
type: :atom,
|
type: :atom,
|
||||||
doc: "The action to be triggered"
|
doc: "The action to be triggered"
|
||||||
],
|
],
|
||||||
condition: [
|
where: [
|
||||||
type: :any,
|
type: :any,
|
||||||
doc: "The filter expression to determine if something should be triggered"
|
doc: "The filter expression to determine if something should be triggered"
|
||||||
]
|
]
|
||||||
|
@ -39,5 +39,10 @@ defmodule AshOban do
|
||||||
sections: [@triggers]
|
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
|
end
|
||||||
|
|
14
lib/verifiers/define_schedulers.ex
Normal file
14
lib/verifiers/define_schedulers.ex
Normal file
|
@ -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
|
|
@ -9,7 +9,9 @@ defmodule AshObanTest do
|
||||||
|
|
||||||
oban do
|
oban do
|
||||||
triggers do
|
triggers do
|
||||||
trigger :process, expr(processed != true)
|
trigger :process do
|
||||||
|
where expr(processed != true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue