Skip to main content

Parker Selbert

sorentwo

sorentwo

Oban - Priority

Did you know that you can prioritize or de-prioritize jobs in a queue by setting a priority from 0-3? Rather than executing in the order they were scheduled, higher priority jobs execute first. https://hexdocs.pm/oban/Oban.html#module-prioritizing-jobs
# Configure uniqueness only based on the id :id field
defmodule MyApp.BusinessWorker do
  use Oban.Worker, queue: :events, priority: 1

  # ...
end

# Manually set a higher priority for a job on the "mega" plan
MyApp.BusinessWorker.new(%{id: 1, plan: "mega"}, priority: 0)

# Manually set a lower priority for a job on the "free" plan
MyApp.BusinessWorker.new(%{id: 1, plan: "free"}, priority: 3)
11 upvotes

© 2021 Zest Creative, LLC