Hi friends, I created a function and module based on Oban
README, but it does not work I think.
defmodule MyApp.Business do
use Oban.Worker, queue: :events
@impl Oban.Worker
def perform(%Oban.Job{args: %{"id" => id} = args}) do
case args do
%{"in_the" => "business"} ->
IO.inspect("business")
%{"vote_for" => vote} ->
IO.inspect(vote)
_ ->
IO.inspect("model")
end
:ok
end
end
After that
%{id: 98, vote_for: "none of the above"}
|> MyApp.Business.new(queue: :special, max_attempts: 5) #or |> MyApp.Business.new()
|> Oban.insert()
and it shows me this:
{:ok,
%Oban.Job{
__meta__: #Ecto.Schema.Metadata<:loaded, "public", "oban_jobs">,
args: %{id: 98, vote_for: "none of the above"},
attempt: 0,
attempted_at: nil,
attempted_by: nil,
cancelled_at: nil,
completed_at: nil,
conf: nil,
conflict?: false,
discarded_at: nil,
errors: [],
id: 3,
inserted_at: nil,
max_attempts: 5,
meta: %{},
priority: 0,
queue: "special",
replace: nil,
scheduled_at: nil,
state: "available",
tags: [],
unique: nil,
unsaved_error: nil,
worker: "MyApp.Business"
}}
It does not print anything
my config:
config :trackapp, Oban,
repo: Trackapp.Repo,
plugins: [Oban.Plugins.Pruner],
queues: [default: 10]