Skip to content

Commit 3669fb4

Browse files
committed
force connection to configured database
1 parent e20d376 commit 3669fb4

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

app/models/solid_queue/record.rb

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,21 @@ class Record < ActiveRecord::Base
66

77
connects_to(**SolidQueue.connects_to) if SolidQueue.connects_to
88

9-
def self.non_blocking_lock
10-
if SolidQueue.use_skip_locked
11-
lock(Arel.sql("FOR UPDATE SKIP LOCKED"))
12-
else
13-
lock
9+
class << self
10+
def connection
11+
if SolidQueue.connects_to.present?
12+
connected_to(role: :writing) { super }
13+
else
14+
super
15+
end
16+
end
17+
18+
def non_blocking_lock
19+
if SolidQueue.use_skip_locked
20+
lock(Arel.sql("FOR UPDATE SKIP LOCKED"))
21+
else
22+
lock
23+
end
1424
end
1525
end
1626
end

0 commit comments

Comments
 (0)