Skip to content

Bulk adding jobs to a batch - how to combine bulk and batch? #1186

Answered by bensheldon
amo13 asked this question in Q&A
Discussion options

You must be logged in to vote

A Batch already Bulk enqueues.

GoodJob::Batch uses it's own bulking wrapper (a GoodJob::Bulk::Buffer, which is the lower-level object also used by GoodJob::Bulk) to capture jobs, so creating a new GoodJob::Bulk will intercept those jobs and not add them to the batch:

def add(active_jobs = nil, &block)
record.save if record.new_record?
buffer = Bulk::Buffer.new
buffer.add(active_jobs)
buffer.capture(&block) if block
self.class.within_thread(batch_id: id) do
buffer.enqueue
end
buffer.active_jobs
end

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by amo13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants