Skip to content

Commit

Permalink
use env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ankithads committed Jun 25, 2024
1 parent 59aab33 commit 55741c3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
6 changes: 0 additions & 6 deletions bin/que
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ OptionParser.new do |opts|
$stdout.puts opts
exit 0
end

opts.on("--using-lock-database [USING_LOCK_DATABSE]", FalseClass, "sets if we want to use seperate database for locking") do |using_lock_database|
options.using_lock_database = using_lock_database
end
end.parse!(ARGV)
# rubocop:enable Metrics/LineLength

Expand All @@ -97,7 +93,6 @@ cursor_expiry = options.cursor_expiry || wake_interval
worker_count = options.worker_count || 1
timeout = options.timeout
secondary_queues = options.secondary_queues || []
using_lock_database = options.using_lock_database || false

Que.logger ||= Logger.new(STDOUT)

Expand All @@ -123,7 +118,6 @@ worker_group = Que::WorkerGroup.start(
lock_window: options.lock_window,
lock_budget: options.lock_budget,
secondary_queues: secondary_queues,
using_lock_database: using_lock_database,
)

if options.metrics_port
Expand Down
4 changes: 2 additions & 2 deletions lib/que/locker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ class Locker
),
].freeze

def initialize(queue:, cursor_expiry:, window: nil, budget: nil, secondary_queues: [], using_lock_database: false)
def initialize(queue:, cursor_expiry:, window: nil, budget: nil, secondary_queues: [])
@queue = queue
@cursor_expiry = cursor_expiry
@queue_cursors = {}
@queue_expires_at = {}
@secondary_queues = secondary_queues
@consolidated_queues = Array.wrap(queue).concat(secondary_queues)
@using_lock_database = using_lock_database
@using_lock_database = ENV.fetch("YUGABYTE_QUE_WORKER_ENABLED", false)

if @using_lock_database
@lock_database_connection = LockDataBaseRecord.connection
Expand Down
6 changes: 2 additions & 4 deletions lib/que/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ def initialize(
lock_cursor_expiry: DEFAULT_WAKE_INTERVAL,
lock_window: nil,
lock_budget: nil,
secondary_queues: [],
using_lock_database: false
secondary_queues: []
)
@queue = queue
@wake_interval = wake_interval
Expand All @@ -135,8 +134,7 @@ def initialize(
cursor_expiry: lock_cursor_expiry,
window: lock_window,
budget: lock_budget,
secondary_queues: secondary_queues,
using_lock_database: using_lock_database,
secondary_queues: secondary_queues
)
end

Expand Down
6 changes: 3 additions & 3 deletions spec/lib/que/worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class ExceptionalJobWithCustomLogging < ExceptionalJob
FakeJob.enqueue(1)

expect(Que).
to receive(:execute).with(:lock_job, ["default", 0]).and_raise(PG::Error)
to receive(:execute).with(:lock_job, include("default", 0)).and_raise(PG::Error)
expect(subject).to eq(:postgres_error)
end
end
Expand All @@ -216,7 +216,7 @@ class ExceptionalJobWithCustomLogging < ExceptionalJob
FakeJob.enqueue(1)

expect(Que).
to receive(:execute).with(:lock_job, ["default", 0]).
to receive(:execute).with(:lock_job, include("default", 0)).
and_raise(ActiveRecord::ConnectionTimeoutError)
expect(subject).to eq(:postgres_error)
end
Expand All @@ -227,7 +227,7 @@ class ExceptionalJobWithCustomLogging < ExceptionalJob
FakeJob.enqueue(1)

expect(Que).
to receive(:execute).with(:lock_job, ["default", 0]).
to receive(:execute).with(:lock_job, include("default", 0)).
and_raise(ActiveRecord::ConnectionNotEstablished)
expect(subject).to eq(:postgres_error)
end
Expand Down

0 comments on commit 55741c3

Please sign in to comment.