mirror of
https://github.com/ash-project/ash_oban.git
synced 2024-09-19 21:03:00 +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
|
||||
@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
|
||||
|
|
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
|
||||
triggers do
|
||||
trigger :process, expr(processed != true)
|
||||
trigger :process do
|
||||
where expr(processed != true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue