From cfe677f2a2c76ab283fe847e4c4a5e6f4d73f582 Mon Sep 17 00:00:00 2001 From: Parker Selbert Date: Mon, 8 Apr 2024 19:55:09 +0100 Subject: [PATCH] Add :oban_draining to process dict while draining The flag marks the test process while draining to give hints to the executor and engines. --- lib/oban/queue/drainer.ex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/oban/queue/drainer.ex b/lib/oban/queue/drainer.ex index d532030a..bdb8b924 100644 --- a/lib/oban/queue/drainer.ex +++ b/lib/oban/queue/drainer.ex @@ -9,6 +9,8 @@ defmodule Oban.Queue.Drainer do @infinite 100_000_000 def drain(%Config{} = conf, [_ | _] = opts) do + Process.put(:oban_draining, true) + args = opts |> Map.new() @@ -19,6 +21,8 @@ defmodule Oban.Queue.Drainer do |> Map.update!(:queue, &to_string/1) drain(conf, %{cancelled: 0, discard: 0, failure: 0, snoozed: 0, success: 0}, args) + after + Process.delete(:oban_draining) end defp stage_scheduled(conf, queue, with_scheduled) do