From 1c3f5f6f2ae307470ff7112e1ed0280bd95d22d1 Mon Sep 17 00:00:00 2001 From: Yousef Janajri Date: Fri, 1 Sep 2023 14:48:52 -0400 Subject: [PATCH] improvement: support overriding job opts in run_trigger --- lib/ash_oban.ex | 4 ++-- lib/changes/builtin_changes.ex | 4 ++-- lib/changes/run_oban_trigger.ex | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ash_oban.ex b/lib/ash_oban.ex index 9cc6b2f..538d93c 100644 --- a/lib/ash_oban.ex +++ b/lib/ash_oban.ex @@ -235,7 +235,7 @@ defmodule AshOban do |> Oban.insert!() end - def run_trigger(%resource{} = record, trigger) do + def run_trigger(%resource{} = record, trigger, oban_job_opts) do trigger = case trigger do %AshOban.Trigger{} -> @@ -257,7 +257,7 @@ defmodule AshOban do end %{primary_key: Map.take(record, primary_key), metadata: metadata} - |> trigger.worker.new() + |> trigger.worker.new(oban_job_opts) |> Oban.insert!() end diff --git a/lib/changes/builtin_changes.ex b/lib/changes/builtin_changes.ex index 4e9eda0..8eae45b 100644 --- a/lib/changes/builtin_changes.ex +++ b/lib/changes/builtin_changes.ex @@ -1,7 +1,7 @@ defmodule AshOban.Changes.BuiltinChanges do @moduledoc "Builtin changes for `AshOban`" - def run_oban_trigger(trigger_name) do - {AshOban.Changes.RunObanTrigger, trigger: trigger_name} + def run_oban_trigger(trigger_name, oban_job_opts \\ []) do + {AshOban.Changes.RunObanTrigger, trigger: trigger_name, oban_job_opts: oban_job_opts} end end diff --git a/lib/changes/run_oban_trigger.ex b/lib/changes/run_oban_trigger.ex index e24849e..4eddbd5 100644 --- a/lib/changes/run_oban_trigger.ex +++ b/lib/changes/run_oban_trigger.ex @@ -13,7 +13,7 @@ defmodule AshOban.Changes.RunObanTrigger do end Ash.Changeset.after_action(changeset, fn _changeset, result -> - AshOban.run_trigger(result, trigger) + AshOban.run_trigger(result, trigger, opts[:oban_job_opts] || []) {:ok, result} end) end