我进行API调用以获取电子邮件地址。成功之后我想把这个电子邮件地址传递给另一份工作。我使用sidekiq和sidekiq-batch宝石。
class HandleWebhookJob
def perform
batch = Sidekiq::Batch.new
batch.description = "Handling webhook"
batch.on(:success, HandleWebhookJob::OtherJob, { email: @email })
batch.jobs do
@email = GetEmailJob.perform_async # returns email address
end
end
class OtherJob
def on_success(status, options)
puts options # no email address here - nil
# need to pass it to UseEmailJob.perfom_async(options[:email])
end
end
end
我假设将GetEmailJob的结果分配给@email将不起作用。无法找到如何执行此操作的示例,如果可能的话。
我想你在jid
得到了@email
。你能用GetEmailJob
密钥将prefix:jid
中的电子邮件保存到某个存储空间(例如redis)并从那里取出吗?