Skip to content

Commit

Permalink
Use ActiveSupport::IsolatedExecutionState to honor user isolation lev…
Browse files Browse the repository at this point in the history
…el setting
  • Loading branch information
jpcamara committed Feb 5, 2024
1 parent bca41d6 commit cc2d1e3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/solid_queue/job_batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class JobBatch < Record

class << self
def current_batch_id
Thread.current[:current_batch_id]
ActiveSupport::IsolatedExecutionState[:current_batch_id]
end

def enqueue(attributes = {})
Expand All @@ -20,13 +20,13 @@ def enqueue(attributes = {})
job_batch = nil
transaction do
job_batch = create!(batch_attributes(attributes))
Thread.current[:current_batch_id] = job_batch.id
ActiveSupport::IsolatedExecutionState[:current_batch_id] = job_batch.id
yield
end

job_batch
ensure
Thread.current[:current_batch_id] = previous_batch_id
ActiveSupport::IsolatedExecutionState[:current_batch_id] = previous_batch_id
end

def dispatch_finished_batches
Expand Down

0 comments on commit cc2d1e3

Please sign in to comment.