From 515664079de092e47ce0aa986df6cfb30c996605 Mon Sep 17 00:00:00 2001 From: "Ben Sheldon [he/him]" Date: Fri, 26 Nov 2021 09:57:40 -0800 Subject: [PATCH] Remove Concurrent::Delay wrapping of database-loading methods (#458) --- lib/good_job/job_performer.rb | 7 ++----- lib/good_job/lockable.rb | 6 ++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/good_job/job_performer.rb b/lib/good_job/job_performer.rb index 87814f558..ba89230ed 100644 --- a/lib/good_job/job_performer.rb +++ b/lib/good_job/job_performer.rb @@ -13,9 +13,6 @@ class JobPerformer # @param queue_string [String] Queues to execute jobs from def initialize(queue_string) @queue_string = queue_string - - @job_query = Concurrent::Delay.new { GoodJob::Execution.queue_string(queue_string) } - @parsed_queues = Concurrent::Delay.new { GoodJob::Execution.queue_parser(queue_string) } end # A meaningful name to identify the performer in logs and for debugging. @@ -65,11 +62,11 @@ def next_at(after: nil, limit: nil, now_limit: nil) attr_reader :queue_string def job_query - @job_query.value + @_job_query ||= GoodJob::Execution.queue_string(queue_string) end def parsed_queues - @parsed_queues.value + @_parsed_queues ||= GoodJob::Execution.queue_parser(queue_string) end end end diff --git a/lib/good_job/lockable.rb b/lib/good_job/lockable.rb index 19c34341b..f809146eb 100644 --- a/lib/good_job/lockable.rb +++ b/lib/good_job/lockable.rb @@ -24,7 +24,7 @@ module Lockable included do # Default column to be used when creating Advisory Locks - class_attribute :advisory_lockable_column, instance_accessor: false, default: Concurrent::Delay.new { primary_key } + class_attribute :advisory_lockable_column, instance_accessor: false, default: nil # Default Postgres function to be used for Advisory Locks class_attribute :advisory_lockable_function, default: "pg_try_advisory_lock" @@ -161,10 +161,8 @@ def with_advisory_lock(column: _advisory_lockable_column, function: advisory_loc end end - # Allow advisory_lockable_column to be a `Concurrent::Delay` def _advisory_lockable_column - column = advisory_lockable_column - column.respond_to?(:value) ? column.value : column + advisory_lockable_column || primary_key end def supports_cte_materialization_specifiers?