Skip to content

Commit

Permalink
Merge pull request #380 from gocardless/expose-locker
Browse files Browse the repository at this point in the history
Make the current Locker instance available via Que.locker
  • Loading branch information
ZimbiX authored Sep 1, 2022
2 parents 50fe308 + 28a3cbf commit b138b29
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/que/locker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
require 'set'

module Que
class << self
attr_accessor :locker
end

Listener::MESSAGE_FORMATS[:job_available] =
{
queue: String,
Expand Down Expand Up @@ -71,6 +75,11 @@ def initialize(
Que.assert Array, worker_priorities
worker_priorities.each { |p| Que.assert([Integer, NilClass], p) }

# We assign this globally because we only ever expect one locker to be
# created per worker process. This can be used by middleware or external
# code to access the locker during runtime.
Que.locker = self

# We use a JobBuffer to track jobs and pass them to workers, and a
# ResultQueue to receive messages from workers.
@job_buffer = JobBuffer.new(
Expand Down

0 comments on commit b138b29

Please sign in to comment.