2023-09-01 03:25:05 +12:00
|
|
|
defmodule AshOban.Test.Triggered do
|
2023-12-13 03:44:35 +13:00
|
|
|
@moduledoc false
|
2023-09-01 03:25:05 +12:00
|
|
|
use Ash.Resource,
|
|
|
|
data_layer: Ash.DataLayer.Ets,
|
|
|
|
extensions: [AshOban]
|
|
|
|
|
|
|
|
oban do
|
|
|
|
api AshOban.Test.Api
|
|
|
|
|
|
|
|
triggers do
|
|
|
|
trigger :process do
|
|
|
|
action :process
|
|
|
|
where expr(processed != true)
|
|
|
|
worker_read_action(:read)
|
|
|
|
end
|
|
|
|
|
|
|
|
trigger :process_2 do
|
|
|
|
action :process
|
|
|
|
where expr(processed != true)
|
|
|
|
worker_read_action(:read)
|
|
|
|
scheduler_cron false
|
|
|
|
end
|
|
|
|
end
|
2024-02-15 05:28:52 +13:00
|
|
|
|
|
|
|
scheduled_actions do
|
|
|
|
schedule :say_hello, "0 0 1 1 *"
|
|
|
|
end
|
2023-09-01 03:25:05 +12:00
|
|
|
end
|
|
|
|
|
|
|
|
actions do
|
|
|
|
defaults [:create]
|
|
|
|
|
|
|
|
read :read do
|
|
|
|
primary? true
|
|
|
|
pagination keyset?: true
|
|
|
|
end
|
|
|
|
|
|
|
|
update :process do
|
|
|
|
change set_attribute(:processed, true)
|
|
|
|
end
|
2024-02-15 05:28:52 +13:00
|
|
|
|
|
|
|
action :say_hello, :string do
|
|
|
|
run fn input, _ ->
|
|
|
|
{:ok, "Hello"}
|
|
|
|
end
|
|
|
|
end
|
2023-09-01 03:25:05 +12:00
|
|
|
end
|
|
|
|
|
|
|
|
ets do
|
|
|
|
private? true
|
|
|
|
end
|
|
|
|
|
|
|
|
attributes do
|
|
|
|
uuid_primary_key :id
|
|
|
|
end
|
|
|
|
end
|