Skip to content

Commit 65c8c32

Browse files
committed
process sis batches using account-specific strands, closes #4415
Change-Id: I69b41689aef047f5302955c27e94c76ece0236f4 Reviewed-on: https://gerrit.instructure.com/3688 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: JT Olds <jt@instructure.com> Reviewed-by: Zach Wily <zach@instructure.com>
1 parent 0bde99c commit 65c8c32

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

app/models/sis_batch.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def process
9090
self.workflow_state = "failed"
9191
self.save
9292
end
93-
handle_asynchronously_with_queue :process, 'sis_imports'
93+
handle_asynchronously :process, :strand => proc { |sis_batch| "sis_batch:account:#{sis_batch.account_id}" }
9494

9595
named_scope :needs_processing, lambda{
9696
{:conditions => ["sis_batches.workflow_state = 'needs_processing'"], :order => :created_at}

config/delayed_jobs.yml.example

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ production:
55
max_priority: 10
66
- queue: canvas_queue
77
workers: 4
8-
9-
# warning: don't set the worker pool size to be greater than 1 if you want
10-
# sis imports to be processed serially
11-
- queue: sis_imports
12-
workers: 1
13-
14-
- periodic: config/periodic_jobs.rb
158
max_run_time: 28800
169
# if set, workers will process this many jobs and then die, causing the pool
1710
# to spawn another worker. this can help return memory to the OS.
@@ -23,4 +16,3 @@ production:
2316
default:
2417
workers:
2518
- queue: canvas_queue
26-
- periodic: config/periodic_jobs.rb

vendor/plugins/delayed_job/lib/delayed/message_sending.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ def send_later(method, *args)
55
end
66

77
def send_later_enqueue_args(method, enqueue_args = {}, *args)
8+
# support procs/methods as enqueue arguments
9+
duped = false
10+
enqueue_args.each do |k,v|
11+
if v.respond_to?(:call)
12+
enqueue_args = enqueue_args.dup unless duped
13+
duped = true
14+
enqueue_args[k] = v.call(self)
15+
end
16+
end
17+
818
Delayed::Job.enqueue(Delayed::PerformableMethod.new(self, method.to_sym, args), enqueue_args)
919
end
1020

0 commit comments

Comments
 (0)