workers: make custom filtering ahead of enqueue possible
This commit is contained in:
parent
25d24cc5f6
commit
ed4019e7a3
1 changed files with 6 additions and 1 deletions
|
@ -38,7 +38,7 @@ defmacro __using__(opts) do
|
||||||
|
|
||||||
alias Oban.Job
|
alias Oban.Job
|
||||||
|
|
||||||
def enqueue(op, params, worker_args \\ []) do
|
defp do_enqueue(op, params, worker_args \\ []) do
|
||||||
params = Map.merge(%{"op" => op}, params)
|
params = Map.merge(%{"op" => op}, params)
|
||||||
queue_atom = String.to_atom(unquote(queue))
|
queue_atom = String.to_atom(unquote(queue))
|
||||||
worker_args = worker_args ++ WorkerHelper.worker_args(queue_atom)
|
worker_args = worker_args ++ WorkerHelper.worker_args(queue_atom)
|
||||||
|
@ -48,11 +48,16 @@ def enqueue(op, params, worker_args \\ []) do
|
||||||
|> Oban.insert()
|
|> Oban.insert()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def enqueue(op, params, worker_args \\ []),
|
||||||
|
do: do_enqueue(op, params, worker_args)
|
||||||
|
|
||||||
@impl Oban.Worker
|
@impl Oban.Worker
|
||||||
def timeout(_job) do
|
def timeout(_job) do
|
||||||
queue_atom = String.to_atom(unquote(queue))
|
queue_atom = String.to_atom(unquote(queue))
|
||||||
Config.get([:workers, :timeout, queue_atom], :timer.minutes(1))
|
Config.get([:workers, :timeout, queue_atom], :timer.minutes(1))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defoverridable enqueue: 3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue