Skip to content

Commit

Permalink
Remove Concurrent::Delay wrapping of database-loading methods (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon committed Nov 26, 2021
1 parent 99696f1 commit 5156640
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
7 changes: 2 additions & 5 deletions lib/good_job/job_performer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
6 changes: 2 additions & 4 deletions lib/good_job/lockable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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?
Expand Down

0 comments on commit 5156640

Please sign in to comment.