Skip to content

Commit

Permalink
Generate and expose a uuid for basic producers
Browse files Browse the repository at this point in the history
The UUID aids in identifying orphaned jobs or churning producers.
  • Loading branch information
sorentwo committed Jun 14, 2023
1 parent 55f0d8e commit a4ad81c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/oban/engines/basic.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ defmodule Oban.Engines.Basic do
|> Map.new()
|> Map.put_new(:paused, false)
|> Map.put_new(:refresh_interval, :timer.seconds(30))
|> Map.put_new(:uuid, Ecto.UUID.generate())
|> Map.merge(%{name: conf.name, node: conf.node})
|> Map.merge(%{started_at: utc_now(), updated_at: utc_now()})

Expand Down Expand Up @@ -110,7 +111,7 @@ defmodule Oban.Engines.Basic do
|> select([j, _], j)

updates = [
set: [state: "executing", attempted_at: utc_now(), attempted_by: [meta.node]],
set: [state: "executing", attempted_at: utc_now(), attempted_by: [meta.node, meta.uuid]],
inc: [attempt: 1]
]

Expand Down
2 changes: 1 addition & 1 deletion test/oban_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ defmodule ObanTest do

alpha_state = Oban.check_queue(name, queue: :alpha)

assert %{limit: 1, node: _, paused: false} = alpha_state
assert %{limit: 1, node: _, paused: false, uuid: _} = alpha_state
assert %{queue: "alpha", running: [_], started_at: %DateTime{}} = alpha_state

assert %{limit: 2, queue: "gamma", running: [_]} = Oban.check_queue(name, queue: :gamma)
Expand Down

0 comments on commit a4ad81c

Please sign in to comment.