Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the current Locker instance available via Que.locker #380

Merged
merged 1 commit into from
Sep 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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