diff --git a/README.md b/README.md index 59d68bbe..72042259 100644 --- a/README.md +++ b/README.md @@ -681,15 +681,15 @@ Batches track a set of jobs, and enqueue an optional callback job when all of th OtherJob.perform_later end - # When these jobs have finished, it will enqueue your `MyBatchCallbackJob.perform_later(batch, options)` + # When these jobs have finished, it will enqueue your `MyBatchCallbackJob.perform_later(batch, context)` class MyBatchCallbackJob < ApplicationJob - # Callback jobs must accept a `batch` and `options` argument - def perform(batch, params) + # Callback jobs must accept a `batch` and `context` argument + def perform(batch, context) # The batch object will contain the Batch's properties, which are mutable batch.properties[:user] # => - # Params is a hash containing additional context (more may be added in the future) - params[:event] # => :finish, :success, :discard + # Context is a hash containing additional context (more may be added in the future) + context[:event] # => :finish, :success, :discard end end ``` @@ -757,19 +757,19 @@ Batch callbacks are Active Job jobs that are enqueued at certain events during t - `:success` - Enqueued only when all jobs in the batch have finished and succeeded. - `:discard` - Enqueued immediately the first time a job in the batch is discarded. -Callback jobs must accept a `batch` and `params` argument in their `perform` method: +Callback jobs must accept a `batch` and `context` argument in their `perform` method: ```ruby class MyBatchCallbackJob < ApplicationJob - def perform(batch, params) + def perform(batch, context) # The batch object will contain the Batch's properties batch.properties[:user] # => # Batches are mutable batch.properties[:user] = User.find(2) batch.save - # Params is a hash containing additional context (more may be added in the future) - params[:event] # => :finish, :success, :discard + # Context is a hash containing additional context (more may be added in the future) + context[:event] # => :finish, :success, :discard end end ``` @@ -811,7 +811,7 @@ class WorkJob < ApplicationJob end class BatchJob < ApplicationJob - def perform(batch, options) + def perform(batch, context) if batch.properties[:stage].nil? batch.enqueue(stage: 1) do WorkJob.perform_later('a')